Troubleshooting SQLite with the Entity Framework 6 Designer
SQLite database with the Entity Framework 6 EDM Wizard and Designer is a popular toolset, but it's also rife with problems.
Join the DZone community and get the full member experience.Join For Free
Many users would like to be able to use the SQLite database with the Entity Framework 6 EDM Wizard and Designer, but looking at Stack Overflow, they often face problems attempting to do that. This blog post describes the steps required to do that, and gives some troubleshooting advice and tips.
Install the SQLite DDEX provider
In order to use the Entity Data Model Wizard to generate a Code First or EDMX Model from an existing database, you must be able to connect to the database from Server Explorer in Visual Studio. In order to do that, a so called DDEX provider for the database and Visual Studio version in use must be installed.
For SQLite you must download the provider fromhttp://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki - this page is an unreadable mess, sadly.
For Visual Studio 2013, the download you need is named: sqlite-netFx451-setup-bundle-x86-2013-18.104.22.168.exe for the current version of the ADO.NET provider, so 1.0.94 might change to 1.0.95 or higher in the future.
It is important that the DDEXprovider version matches the version of the current SQLite EF6 NuGet package that you use in your project!
Make sure to enable Visual Studio integration and GAC registration during installation.
You can check which version of the DDEX provider you have installed in “Add or Remove Programs”:
Once installed, you can add a connection to your SQLite database from Server Explorer:
Add the correct SQLite EF6 NuGet package to your project
To demonstrate using the SQLite EF6 provider, let’s go through creating a console app in Visual Studio 2013, that uses the Chinook sample database that we connected to above.
To add the SQLite EF6 provider to your project, select the System.Data.SQLite.EF6 package:
This package will install all other required dependencies, including Entity Framework 6.1.1.
After installation of this package in a project that target .NET 4.5, your packages.config should look like this:
And the system.data section of your app.config file should look like this:
Now BUILD your project
You should now be able to add a EDMX or Code First based model to your project, using Add New Item. Data, ADO.NET Entity Data Model:
If you are unable to see the connection to the SQLite database we made earlier, here are a couple of tips:
Try building the project and possible changing the build configuration to x86 has worked for me.
Hope this helps!
Published at DZone with permission of Erik Ejlskov Jensen, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.