Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does the SQLite Entity Framework 6 provider handle Guids?

I am porting our product's database to SQLite from another product that supported Guids. As we know, SQLite does not support Guids. I've got created an entity framework 6 model from my database (database first) and I need to build a query from C# that compares the Guid to one passed from the code.

The thing is I can't find any documentation on how the SQLite Entity Framework provider handles Guids. A web search didn't find anything useful for me, either. Just questions about using Entity Framework with SQLite.

Can anybody point me to the documentation, or maybe tell me how to work with Guids in a SQLite database through an EF6 model?

like image 343
Tony Vitabile Avatar asked Dec 03 '14 18:12

Tony Vitabile


People also ask

Does Entity Framework work with SQLite?

This database provider allows Entity Framework Core to be used with SQLite. The provider is maintained as part of the Entity Framework Core project.

Does EF core 6 require .NET 6?

EF Core 6.0 requires . NET 6.

How does Entity Framework core work?

With EF Core, data access is performed using a model. A model is made up of entity classes and a context object that represents a session with the database. The context object allows querying and saving data. For more information, see Creating a Model.


1 Answers

It appears that this was resolved in 1.0.95 however broken again in 1.0.97. The solution is to set the BinaryGUID property on the connection string to true and set the following environment variable (before you make the connection)

Environment.SetEnvironmentVariable("AppendManifestToken_SQLiteProviderManifest",";BinaryGUID=True;");

Data Source=c:\mydb.db;Version=3;BinaryGUID=True;

https://www.connectionstrings.com/sqlite/

like image 82
Greg Avatar answered Sep 25 '22 21:09

Greg