简体   繁体   中英

SQLite with Entity Framework : no data provider for SQLite available in VS2013

There are many questions on Stackoverflow on this topic. I tried most of the proposed answers but none of them worked for me.

  • My setup : Win 7 32 bits + VS2013 Update 5
  • I installed sqlite-netFx46-setup-bundle-x86-2015-1.0.108.0.exe (full install)
  • Then I created a new .NET 4.6 console project
  • Then I installed SQLite Nuget packages
  • Additionally, I built my project in AnyCPU and made another attempt in x86
  • Then I tried to add entity data model (Add -> New Items -> ADO.NET Entity Data Model)

Whatever the option I chose (EF Designer, Code First) no provider for SQlite is visible when I try to create the connection.

My configuration file :

<?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.6" />
    </startup>
    <entityFramework>
        <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
            <parameters>
                <parameter value="v11.0" />
            </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>
    <system.data>
        <DbProviderFactories>
            <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>
</configuration>

My package config :

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="EntityFramework" version="6.0.0" targetFramework="net46" />
  <package id="System.Data.SQLite" version="1.0.108.0" targetFramework="net46" />
  <package id="System.Data.SQLite.Core" version="1.0.108.0" targetFramework="net46" />
  <package id="System.Data.SQLite.EF6" version="1.0.108.0" targetFramework="net46" />
  <package id="System.Data.SQLite.Linq" version="1.0.108.0" targetFramework="net46" />
</packages>

EDIT : adding screenshots to clarify the question :

在那里我应该能够设置到我的SQLite DB的连接

What did i do wrong ? Thanks for your help !

Ok, i just figured out what's happening. I simply did not install the proper provider. I should have install sqlite-netFx451-setup-bundle-x86-2013-1.0.108.0.exe

It's not very clear in the System.Data.SQLite wiki, but the year in the file name, is not the release date as i thought, but the VisualStudio version. My mistake was to choose the provider by the desired target .NET version.

Once the correct provider was installed, all just went fine, even if the provider targets .NET 4.5.1 and my project targets .NET 4.6

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM