'No Entity Framework provider found' for EF 6 and SQLite 1.0.96.0

后端 未结 6 1061

I realize there are already several similar questions on this topic, but many of them are from older version of SQLite which did not fully support EF 6 as far as I am aware.

相关标签:
6条回答
  • 2020-12-12 22:38

    I solved same error with just add a single line in App.config

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

    PS: Add provider to <configuration> > <entityFramework> > <providers>

    0 讨论(0)
  • 2020-12-12 22:39

    I finally got it too work

    I'm using : EF 6.1.3 http://www.microsoft.com/en-us/download/details.aspx?id=40762 and System.Data.SQLite 1.0.96.0 sqlite-netFx451-setup-bundle-x86-2013-1.0.96.0.exe

    I followed the description written in: Database first create entity framework 6.1.1 model using system.data.sqlite 1.0.93 (in this description a nuget package of entity framwork is installed -i did it too)

    For the app.config file i used these fixes: https://stackoverflow.com/a/24324212/885349 (written by tomexou)

    Finally SQLite Connector wasn't shown in the ADO.Net Entity Data Model Mapper

    The missing link was the \bin folder. I had to set the "Copy Local" = true setting for following dlls:

    • SQLite.Designer
    • System.Data.SQLite
    • System.Data.SQLite.EF6
    • System.Data.SQLite.Linq

    Only for completeness - added through Nuget and also in \bin folder

    • EntityFramework
    • EntityFramework.SqlServer

    And the SQLite Connection was shown...

    0 讨论(0)
  • 2020-12-12 22:44

    After searching for a week i believe this problem is a feature in development by the sqlite team.

    More information can be found here SQLite connection not appearing in Entity Data Model Wizard

    edit: Maybe looking into some different providers might seem worthwhile. Although i have not tested this myself, http://www.devart.com/dotconnect/ offers some promising alternatives and states EF compatibility.

    0 讨论(0)
  • 2020-12-12 22:47
    public class EFConfiguration : DbConfiguration
    {
        public EFConfiguration()
        {
            SetDefaultConnectionFactory(new LocalDbConnectionFactory("v.11"));
    
            //HACK
            var EF6ProviderServicesType = typeof(System.Data.SQLite.EF6.SQLiteProviderFactory).Assembly.DefinedTypes.First(x => x.Name == "SQLiteProviderServices");
            var EF6ProviderServices = (DbProviderServices)Activator.CreateInstance(EF6ProviderServicesType);
            SetProviderServices("System.Data.SQLite.EF6", EF6ProviderServices);
            SetProviderServices("System.Data.SqlClient", System.Data.Entity.SqlServer.SqlProviderServices.Instance);
            SetProviderFactory("System.Data.SQLite.EF6", System.Data.SQLite.EF6.SQLiteProviderFactory.Instance);
            SetProviderFactory("System.Data.SQLite", System.Data.SQLite.SQLiteFactory.Instance);
        }
    }
    
    0 讨论(0)
  • 2020-12-12 22:49

    Try these tweaks:

    <providers>
      ...
      <provider invariantName="System.Data.SQLite" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6"/>
    </providers>
    
    <system.data>
        <DbProviderFactories>
            <remove invariant="System.Data.SQLite.EF6" />
            <add name="SQLite Data Provider" invariant="System.Data.SQLite" description="Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />
        </DbProviderFactories>
    </system.data>
    

    See Entity Framework 6 + SQLite

    0 讨论(0)
  • 2020-12-12 22:52

    Here is a working app.config

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <configSections>
        <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
        <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.2" />
      </startup>
    
      <entityFramework>
        <providers>
          <provider invariantName="System.Data.SQLite" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6"/>
        </providers>
      </entityFramework>
    
      <connectionStrings>
        <!-- use AppDomain.SetData to set the DataDirectory -->
        <add name="MapDbConnectionStr" connectionString="Data Source=|DataDirectory|MapDb.sqlite" providerName="System.Data.SQLite" />
      </connectionStrings>
    
      <system.data>
        <DbProviderFactories>
          <remove invariant="System.Data.SQLite.EF6" />
          <add name="SQLite Data Provider" invariant="System.Data.SQLite" description="Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />
        </DbProviderFactories>
      </system.data>
    
    
    
    </configuration>
    
    0 讨论(0)
提交回复
热议问题