Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use EF with SQLite and Visual Studio 2013

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>
like image 214
Tom Avatar asked Nov 27 '25 05:11

Tom


1 Answers

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.

like image 183
ErikEJ Avatar answered Nov 28 '25 21:11

ErikEJ



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!