3

I'd like to use SQLite with Entity Framework and Visual Studio 2013 Desktop Express.

To do that i have right click on Reference and installed (with selected dependecies) "System.Data.SQLite(X86/x64)" (version 1.0.94.1) NuGet packages

Now if i add a new element to my project and select ADO.NET Entity Data Model i don't see the SQLite Provider: i have only Microsoft SQL Server.

I have .NET Framework 4.5.1 and Windows 7.

This is my App.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
     <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
 </configSections>
 <startup>
     <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
 </startup>
 <system.data>
   <!--
    NOTE: The extra "remove" element below is to prevent the design-time
          support components within EF6 from selecting the legacy ADO.NET
          provider for SQLite (i.e. the one without any EF6 support).  It
          appears to only consider the first ADO.NET provider in the list
          within the resulting "app.config" or "web.config" file.
-->
   <DbProviderFactories>
      <add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".NET Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />
      <remove invariant="System.Data.SQLite" />
      <remove invariant="System.Data.SQLite.EF6" />
      <add name="SQLite Data Provider (Entity Framework 6)" invariant="System.Data.SQLite.EF6" description=".NET Framework Data Provider for SQLite (Entity Framework 6)" type="System.Data.SQLite.EF6.SQLiteProviderFactory, System.Data.SQLite.EF6" />
   </DbProviderFactories>
 </system.data>
 <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
       <parameters>
           <parameter value="mssqllocaldb" />
       </parameters>
    </defaultConnectionFactory>
    <providers>
        <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
        <provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
    </providers>
 </entityFramework>
</configuration>
1

3 Answers 3

3

You must install the DDEX provider from http://system.data.sqlite.org - but the Express versions do not allow installation of any extensions like DDEX providers.

You can install the new Visual Studio 2013 Community. There, go to "Tools", "Extensions and Updates", the type "sqlite ddex" into the search box, and install it.

0

While you have added the nuget packages for SQLite to your project, this is completely separate to the Visual Studio tooling that would be used to scaffold a data model.

You can install the runtime support for Visual Studio from http://system.data.sqlite.org/ - this should allow you to use the Visual Studio support for creating your model.

0

I had to add this in the Providers section of Entity Framework:

<provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />

If you follow EricEJ's tutorial, this should then work for you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.