我正在尝试在SQLite(http://brice-lambson.blogspot.ru/2012/10/entity-framework-on-sqlite.html)上完成Entity Framework 5。我已经安装了SQLite和EF6。但是我收到了一个错误:
'实例'实体框架提供程序类型的成员' System.Data.SQLite.SQLiteFactory,System.Data.SQLite,Version = 1.0.99.0,Culture = neutral,PublicKeyToken = db937bc2d44ff139'没有返回继承自System.Data.Entity.Core.Common.DbProviderServices'的对象。实体框架提供者必须从此类继承并且实例'成员必须返回提供者的单例实例。这可能是因为提供商不支持Entity Framework 6或更高版本;
您能否提示一下可能导致问题的原因?非常感谢!
我的app.config
文件如下所示:
<configuration>
<configSections>
<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>
<defaultConnectionFactory type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6"/>
<providers>
<provider invariantName="System.Data.SQLite"
type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite"/>
<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="ChinookContext"
connectionString="Data Source=|DataDirectory|Chinook_Sqlite_AutoIncrementPKs.sqlite"
providerName="System.Data.SQLite"/>
</connectionStrings>
</configuration>
我安装了以下组件:
答案 0 :(得分:4)
最后我找出了问题。
使用下面列出的app.cong文件进行了一些更正
<?xml version="1.0" encoding="utf-8"?>
并确保: