实体框架6 + SQLite的 [英] Entity Framework 6 + SQLite
问题描述
我试图用EF6阿尔法和SQLite 1.0.66.0
I'm trying to use EF6 alpha and SQLite 1.0.66.0
我的config文件:
My .config file:
<connectionStrings>
<add connectionString="data source=:memory:;" name="TestDbContext" providerName="System.Data.SQLite" />
</connectionStrings>
<entityFramework>
<providers>
<provider invariantName="System.Data.SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite, Version=1.0.66.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139" />
</providers>
</entityFramework>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<system.data>
<DbProviderFactories>
<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, Version=1.0.66.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139" />
</DbProviderFactories>
</system.data>
当我运行
using (var dbContext = new TestDbContext())
{
if (dbContext.Database.Exists())
{
dbContext.Database.Delete();
}
dbContext.Database.Create();
}
我得到一个错误:
I get an error:
System.InvalidOperationException信息:System.InvalidOperationException: 实体框架提供程序类型的实例成员 System.Data.SQLite.SQLiteFactory,System.Data.SQLite, 版本= 1.0.66.0,文化=中性公钥= db937bc2d44ff139' 没有返回一个对象,它继承 System.Data.Entity.Core.Common.DbProviderServices。实体框架 供应商必须扩展这一类的实例成员必须 返回提供的Singleton实例。
System.InvalidOperationException: System.InvalidOperationException: The 'Instance' member of the Entity Framework provider type 'System.Data.SQLite.SQLiteFactory, System.Data.SQLite, Version=1.0.66.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139' did not return an object that inherits from 'System.Data.Entity.Core.Common.DbProviderServices'. Entity Framework providers must extend from this class and the 'Instance' member must return the Singleton instance of the provider..
我是什么做错了吗?
推荐答案
在System.Data.SQLite实体框架供应商将需要更新的实体框架的第6版工作。 (请参阅<一个href="http://entityframework.$c$cplex.com/wikipage?title=Rebuilding%20EF%20providers%20for%20EF6">Rebuilding EF提供商EF6 )
The System.Data.SQLite Entity Framework provider will need to be updated to work with version 6 of the Entity Framework. (See Rebuilding EF providers for EF6)
有关SQLite的,这是一个相当简单的任务:
For SQLite, this is a fairly trivial task:
- 下载并打开System.Data.SQLite.Linq项目
- 删除提及System.Data.Entity.dll
- 添加引用EntityFramework.dll第6版
- 更新破命名空间引用
- 重建提供者
2013年6月21日更新: 我已经在我的博客共享提供的更新版本。请参阅<一href="http://brice-lambson.blogspot.com/2013/06/systemdatasqlite-on-entity-framework-6.html">System.Data.SQLite在实体框架6 了解详情。
Jun 21, 2013 Update: I've shared an updated version of the provider on my blog. See System.Data.SQLite on Entity Framework 6 for more information.
这篇关于实体框架6 + SQLite的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!