我正在尝试创建一个简单的项目来探索 Entity Framework 6 Code First 与 sqlite db 提供程序如何工作,但是当我完成我的应用程序时,我收到错误:
“实体框架提供程序类型
'System.Data.SQLite.SQLiteProviderServices,System.Data.SQLite.Linq,
版本=1.0.91.0,文化=中性,PublicKeyToken=db937bc2d44ff139'
在 ADO.NET 提供程序的应用程序配置文件中注册
无法加载具有不变名称“System.Data.SQLite”的文件。制作
确保使用了程序集限定名称并且程序集是
可供正在运行的应用程序使用。看http://go.microsoft.com/fwlink/?LinkId=260882 http://go.microsoft.com/fwlink/?LinkId=260882了解更多信息。”
我认为这个错误与app.config文件有关。
有人有 Entity Framework 6 + Sqlite 1.0.91 的工作 app.config 文件吗?
这些是我的配置文件内容:
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
</configSections>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework"/>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/>
<provider invariantName="System.Data.SQLite" type="System.Data.SQLite.SQLiteProviderServices, System.Data.SQLite.Linq, Version=1.0.91.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139"/>
</providers>
</entityFramework>
<connectionStrings>
<add name="BloggingContext" connectionString="Data Source=.\animals.sqlite" providerName="System.Data.SQLite"/>
</connectionStrings>
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SQLite"/>
<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>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
首先从提供者部分删除以下行:
<provider invariantName="System.Data.SQLite" type="System.Data.SQLite.SQLiteProviderServices, System.Data.SQLite.Linq, Version=1.0.91.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139"/>
并添加以下行来代替:
<provider invariantName="System.Data.SQLite" type="System.Data.SQLite.SQLiteProviderServices, System.Data.SQLite.Linq" />
欲了解更多信息:使用 Entity Framework 6 和 SQLite 的问题 https://stackoverflow.com/questions/20460357/problems-using-entity-framework-6-and-sqlite
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)