Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Troubleshooting SQLite with the Entity Framework 6 Designer

DZone's Guide to

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.

Free Resource

Traditional relational databases weren’t designed for today’s customers. Learn about the world’s first NoSQL Engagement Database purpose-built for the new era of customer experience.

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-1.0.94.0.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.

image

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”:

image

Once installed, you can add a connection to your SQLite database from Server Explorer:

image

image

image

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:

image

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:

image

And the system.data section of your app.config file should look like this:

image

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:

image

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.

Installing the Entity Framework 6.1.2-beta2 tools have worked very well for me – download link in the blog post here. I think it is due to this fix in the Tools beta.

Hope this helps! 

Learn how the world’s first NoSQL Engagement Database delivers unparalleled performance at any scale for customer experience innovation that never ends.

Topics:
sql ,dotnet ,microsoft ,tools ,visual studio ,.net & windows ,ms-office dev ,windows phone

Published at DZone with permission of Erik Ejlskov Jensen, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}