【发布时间】:2014-03-05 16:08:46
【问题描述】:
我最近将旧项目中的实体框架从版本 4 或 5 升级/更新到版本 6。现在我得到了这个异常:
“System.InvalidOperationException”类型的异常发生在 EntityFramework.dll 但未在用户代码中处理
附加信息:未找到适用于 具有不变名称“System.Data.SqlClient”的 ADO.NET 提供程序。制作 确保提供者在 'entityFramework' 部分中注册 应用程序配置文件。看 http://go.microsoft.com/fwlink/?LinkId=260882 了解更多信息。
我用谷歌搜索了这个错误并遇到了几个 SO 线程,但没有一个包含适合我的解决方案。这就是我的 App.config 的样子:
<?xml version="1.0" encoding="utf-8"?>
<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.SqlConnectionFactory, EntityFramework" />
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
</configuration>
我已经从我的项目中卸载了 Entity Framework 并重新安装了它,删除了对旧 EF 文件的所有引用并重新安装,但对我没有任何作用。我不断收到此错误。
【问题讨论】:
-
那么您是否考虑过降级或您正在尝试使该版本正常工作
-
EF6 有一些对我的项目非常有用的功能。
-
你有什么版本的 Visual Studio,因为我知道 2010 年使用较新的 EF 有问题,我自己有一个问题,请参阅 here
-
Visual Studio 2013 高级版。
标签: c# .net entity-framework ado.net entity-framework-6