错误:发现ADO.NET提供与固定名称“System.Data.SqlClient的”无实体框架提供 [英] Error: No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlClient'

查看:826
本文介绍了错误:发现ADO.NET提供与固定名称“System.Data.SqlClient的”无实体框架提供的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近升级/从版本4或5〜6版本更新实体框架的一个老项目,现在我得到这个异​​常:

I recently upgraded/updated Entity Framework in an old project from version 4 or 5 to version 6. Now I get this exception:

'System.InvalidOperationException'类型的异常发生   EntityFramework.dll但在用户code没有处理

An exception of type 'System.InvalidOperationException' occurred in EntityFramework.dll but was not handled in user code

其它信息:没有实体框架提供发现的   ADO.NET提供与固定名称System.Data.SqlClient的。使   确保供应商是注册在的的EntityFramework部分   应用程序配置文件。看到   <一href="http://go.microsoft.com/fwlink/?LinkId=260882">http://go.microsoft.com/fwlink/?LinkId=260882了解更多信息。

Additional information: No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlClient'. Make sure the provider is registered in the 'entityFramework' section of the application config file. See http://go.microsoft.com/fwlink/?LinkId=260882 for more information.

我一派错误和碰到一对夫妇的SO线程,但他们都不包含在一个解决方案,为我工作。这是我的App.config中是这样的:

I googled the error and came across a couple of SO threads, but none of them contained a solution that works for me. This is what my App.config looks like:

<?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>

我已经卸载实体框架从我的项目,并重新安装了它,删除所有引用旧的EF文件,并​​重新安装,但没有为我工作。我不断收到此错误。

I already uninstalled Entity Framework from my project and re-installed it, deleted all the references to old EF files and re-installed, but nothing works for me. I keep getting this error.

推荐答案

好吧,这是pretty的怪异。我有几个项目:一个是UI项目(一个ASP.NET MVC项目),其他是东西像库项目。该信息库项目有一个参考的EF,但用户界面项目没有(因为它不需要一个,它只是需要以引用其他项目)。当我安装EF的UI项目为好,一切都开始工作。这就是为什么,它增加了这块code到我的web.config:

Ok, this is pretty weird. I have a couple of projects: one is a UI project (an ASP.NET MVC project) and the others are projects for stuff like repositories. The repositories project had a reference to EF, but the UI project didn't (because it didn't need one, it just needed to reference the other projects). After I installed EF for the UI project as well, everything started working. This is why, it added this piece of code to my Web.config:

<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>

这篇关于错误:发现ADO.NET提供与固定名称“System.Data.SqlClient的”无实体框架提供的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆