[英]'No Entity Framework provider found' for EF 6 and SQLite 1.0.96.0
[英]'No Entity Framework provider found' for EF 6 and SQLite 1.0.105.2
我已经尝试了一些关于以前版本的类似问题的答案,但似乎都不起作用:
什么有效:从数据库更新(在 Sqlite Studio 中更改后)。
什么不起作用:从更新的模型生成数据库。
错误消息:未找到具有不变名称“System.Data.Sqlite.EF6”的 ADO.NET 提供程序的实体框架提供程序。
我正在使用 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" />
我的 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="C:\Users\Frederik\Documents\Data\data03.db"'" providerName="System.Data.EntityClient" />
</connectionStrings>
</configuration>
确保DbProviderFactories
和entityFramework
部分存在于您的主项目(启动项目)配置文件中。 您可能在单独的项目中拥有数据访问权限。
在您的配置文件中:
<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>
您需要添加提供者节点
<provider invariantName="System.Data.SQLite" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
正如许多开发人员报告的那样,它也是必要的。 我也有过这样的经历。
还要确保您的连接字符串引用提供程序“System.Data.SQLite”而不是“System.Data.SQLite.EF6”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.