【发布时间】:2013-12-25 22:57:09
【问题描述】:
我正在尝试将实体框架与 SQLite 一起使用。我在将它集成到我的主应用程序时遇到了问题,所以我从头开始做了一个小测试,完全按照http://brice-lambson.blogspot.com/2012/10/entity-framework-on-sqlite.html 上的指示进行
说到底,运行项目时出现如下错误:
找不到 ADO.NET 提供程序的实体框架提供程序 不变名称“System.Data.SQLite”。确保提供者是 在应用程序配置的“entityFramework”部分注册 文件。更多信息请见http://go.microsoft.com/fwlink/?LinkId=260882 信息。
我的 app.config 如下所示:
<?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" />
<!-- 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" />
</providers>
</entityFramework>
<system.data>
<DbProviderFactories>
<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>
<connectionStrings>
<add name="ChinookContext"
connectionString=
"Data Source=|DataDirectory|Chinook_Sqlite_AutoIncrementPKs.sqlite"
providerName="System.Data.SQLite" />
</connectionStrings>
</configuration>
然后我看到了他关于 Entity Framework 6 的帖子。虽然这不是我得到的确切错误,但我尝试通过 NuGet 安装他更新的提供程序。错误消失了,但替换为这个:
无法加载文件或程序集'System.Data.SQLite.Linq, 版本=2.0.88.0,文化=中性,PublicKeyToken=db937bc2d44ff139' 或 它的依赖项之一。定位程序集的清单定义 与程序集引用不匹配。 (HRESULT 的例外情况: 0x80131040)
此外,我的 app.config (略微)更改为:
<?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" />
<!-- 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=2.0.88.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139" />
</providers>
</entityFramework>
<system.data>
<DbProviderFactories>
<add name="SQLite Data Provider" invariant="System.Data.SQLite" description="Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />
<remove invariant="System.Data.SQLite" />
</DbProviderFactories>
</system.data>
<connectionStrings>
<add name="ChinookContext" connectionString="Data Source=|DataDirectory|Chinook_Sqlite_AutoIncrementPKs.sqlite" providerName="System.Data.SQLite" />
</connectionStrings>
</configuration>
我已经尝试了我能想到的所有方法来解决这些错误,但没有任何效果。我尝试过使用其他 SQLite 二进制文件;我尝试手动编辑 SQLite 项目以使用 EF 版本 6;我已经更改了架构,一遍又一遍地添加和删除了 nuget 包,等等。
我不知道从这里去哪里。
【问题讨论】:
-
从提供者部分移除 System.Data.SQLite.Linq。
标签: c# .net entity-framework sqlite entity-framework-6