I am using System.Data.Sqlite 1.0.99 from C#, with it you can call to db with EF. I faced with the problem when selecting FirstOrDefault
by Guid
it return null
(but row with such guid exists in database):
var user = context.Users.FirstOrDefault(x => x.Id == userId); //returns null
Found some information that this is known issue and it was fixed in 1.0.95, but broken again in 1.0.97 and next two solutions:
Solution 1: set the BinaryGUID property on the connection string to true:
Data Source=...;BinaryGUID=True;
Solution 2: set next environment variable (before you make the connection):
Environment.SetEnvironmentVariable("AppendManifestToken_SQLiteProviderManifest", ";BinaryGUID=True;");
Solution 2 works, because (from sqlite site):
AppendManifestToken_SQLiteProviderManifest - If this environment variable is set [to anything], it will be used by the System.Data.SQLite.Linq.SQLiteProviderManifest class (and the System.Data.SQLite.EF6.SQLiteProviderManifest class) to modify future provider manifest tokens by appending the value of the environment variable to the existing provider manifest token, if any. Typically, in order for the constructed provider manifest token to be syntactically correct, the environment variable value [to be appended] must begin with a semicolon.
Solution 1 doesn't work for me because, as I understand, it has an effect only on System.Data.SQLite.Linq.SQLiteProviderManifest.
The Question: Is there any solution to fix this behaviour not to setting environment variable?
Aucun commentaire:
Enregistrer un commentaire