How to use EF with SQLite and Visual Studio 2013

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

To do this, I have a right click on the link and installed (with selected dependencies) "System.Data.SQLite (X86 / x64)" (version 1.0.94.1). NuGet packages

Now if I add a new item to my project and select ADO.NET Entity Data Model, I don't see the SQLite provider: I only have 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>

      

+3
c # sqlite visual-studio visual-studio-2013 entity-framework


source to share


3 answers


You must install the DDEX provider from http://system.data.sqlite.org , but the Express versions do not allow you to install any extensions such as DDEX providers.



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

+3


source to share


As long as you've added the SQLite nuget packages to your project, it depends entirely on the Visual Studio tooling that will be used to create the data model.



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

0


source to share


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

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

      

If you are following EricEJ's guide this should work for you.

0


source to share







All Articles
Loading...
X
Show
Funny
Dev
Pics