简体   繁体   English

EF 6 和 SQLite 1.0.105.2 的“未找到实体框架提供程序”

[英]'No Entity Framework provider found' for EF 6 and SQLite 1.0.105.2

I have tried some answers on similar questions for previous versions, but none seem to work:我已经尝试了一些关于以前版本的类似问题的答案,但似乎都不起作用:

  • Adding a third provider (Sqlite) to the App.config.向 App.config 添加第三个提供程序 (Sqlite)。
  • Changing the connection string provider from Sqlite.EF56 to Sqlite.将连接字符串提供程序从 Sqlite.EF56 更改为 Sqlite。

What works : updating from database (after a change in Sqlite Studio).什么有效:从数据库更新(在 Sqlite Studio 中更改后)。

What doesn't work : generating a database from an updated model.什么不起作用:从更新的模型生成数据库。

Error message : No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.Sqlite.EF6'.错误消息:未找到具有不变名称“System.Data.Sqlite.EF6”的 ADO.NET 提供程序的实体框架提供程序。

I am using Visual Studio 2015. I have installed sqlite-netFx46-setup-bundle-x86-2015-1.0.105.2.exe (for the visual designer) and then added NuGet packages like so:我正在使用 Visual Studio 2015。我已经安装了sqlite-netFx46-setup-bundle-x86-2015-1.0.105.2.exe (用于视觉设计器),然后添加了 NuGet 包,如下所示:

<package id="EntityFramework" version="6.1.3" targetFramework="net45" />   
<package id="System.Data.SQLite" version="1.0.105.2" targetFramework="net45" />
<package id="System.Data.SQLite.Core" version="1.0.105.2" targetFramework="net45" />    
<package id="System.Data.SQLite.EF6" version="1.0.105.2" targetFramework="net45" />
<package id="System.Data.SQLite.Linq" version="1.0.105.2" targetFramework="net45" />

My App.config:我的 App.config:

<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>
  <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>
  <system.data>
    <DbProviderFactories>
      <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" />
      <remove invariant="System.Data.SQLite" />
      <add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".NET Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />
    </DbProviderFactories>
  </system.data>
  <connectionStrings>
    <add name="data03Entities" connectionString="metadata=res://*/Data.Data03.csdl|res://*/Data.Data03.ssdl|res://*/Data.Data03.msl;provider=System.Data.SQLite.EF6;provider connection string='data source=&quot;C:\Users\Frederik\Documents\Data\data03.db&quot;'" providerName="System.Data.EntityClient" />
  </connectionStrings>
</configuration>

Make sure that DbProviderFactories and entityFramework sections are present in your main project's (start-up project) config file.确保DbProviderFactoriesentityFramework部分存在于您的主项目(启动项目)配置文件中。 You probably have data access in separate project.您可能在单独的项目中拥有数据访问权限。

in your config file:在您的配置文件中:

    <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>

you need to add in providers node您需要添加提供者节点

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

as many devs reported that it is needed as well.正如许多开发人员报告的那样,它也是必要的。 I have also experienced that.我也有过这样的经历。

also make sure your connection string is referencing the provider "System.Data.SQLite" not "System.Data.SQLite.EF6"还要确保您的连接字符串引用提供程序“System.Data.SQLite”而不是“System.Data.SQLite.EF6”

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 对于EF 6和SQLite 1.0.96.0,“找不到实体框架提供程序” - 'No Entity Framework provider found' for EF 6 and SQLite 1.0.96.0 找不到实体框架提供者 - No Entity Framework Provider Found System.InvalidOperationException:“没有为 ADO.NET 提供程序找到具有不变名称“System.Data.SQLite”的实体框架提供程序 - System.InvalidOperationException: 'No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SQLite' 找不到ADO.NET提供程序的实体框架提供程序 - No Entity Framework provider found for the ADO.NET provider 带有实体框架的SQLite:VS2013中没有可用的SQLite数据提供程序 - SQLite with Entity Framework : no data provider for SQLite available in VS2013 SQLite&Entity Framework 6“基础数据提供程序无法打开” - SQLite & Entity Framework 6 “The underlying data provider failed to open” 通用实体框架项目“没有为ADO.NET提供者找到实体框架提供者” - Common Entity Framework Project “No Entity Framework provider found for the ADO.NET provider” SQLite Entity Framework 6提供程序如何处理Guids? - How does the SQLite Entity Framework 6 provider handle Guids? 具有SQLite异常的实体框架:底层提供程序在Commit上失败 - Entity Framework with SQLite exception: The underlying provider failed on Commit 找不到实体框架提供程序…不变名称为“ System.Data.SqlClient” - No Entity Framework provider found … with invariant name 'System.Data.SqlClient'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM