Hello.
Are there any classes for reading PRAGMA database properties while using Entity Framework Code-First approach (I'm especially interested in user_version)?
And howto read user_version of a given SQLite database file (for example \\NETWORK SHARE\test.db) in situation when I don't use DbContext?
Thank you.
Howto read PRAGMA user_version?
Re: Howto read PRAGMA user_version?
There are no Entity Framework specific classes for working with user_version pragma. Either create a new ADO.NET connection or access an existing one within a context (var connection = ((IObjectContextAdapter)myDbContext).ObjectContext.Connection;) and execute PRAGMA statements via SQLiteCommand.
Re: Howto read PRAGMA user_version?
Hello again.
I use the following code to read user_version:
and following code to change user_version:
It works perfect for one database.
But when I use one main database and several attached (with different user_version value) - how can I read them all (using .ToList() instead of .FirstOrDefault() returns list with only one element for me)?
And change each one separately?
Thank you in advance.
I use the following code to read user_version:
Code: Select all
((IObjectContextAdapter)myDbContext).ObjectContext.ExecuteStoreQuery<long>("PRAGMA user_version").FirstOrDefault()
Code: Select all
((IObjectContextAdapter)myDbContext).ObjectContext.ExecuteStoreCommand("PRAGMA user_version=XX")
But when I use one main database and several attached (with different user_version value) - how can I read them all (using .ToList() instead of .FirstOrDefault() returns list with only one element for me)?
And change each one separately?
Thank you in advance.
Re: Howto read PRAGMA user_version?
Here is an SQLite documenation: https://sqlite.org/pragma.html#pragma_user_version.
Please specify the exact PRAGMA command you are using to return a result set of user_version values for all (main and attached) databases.
Please specify the exact PRAGMA command you are using to return a result set of user_version values for all (main and attached) databases.
Re: Howto read PRAGMA user_version?
Thank you.
and
works perfectly.
Code: Select all
((IObjectContextAdapter)myDbContext).ObjectContext.ExecuteStoreQuery<long>("PRAGMA main.user_version").FirstOrDefault();
Code: Select all
((IObjectContextAdapter)myDbContext).ObjectContext.ExecuteStoreQuery<long>("PRAGMA AttachedDatabaseName1.user_version").FirstOrDefault();