我该如何解决Entity Framework提供者异常 [英] How do I solve The Entity Framework provider exception

查看:200
本文介绍了我该如何解决Entity Framework提供者异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经将WCF项目发布到服务器上,也已经将MVC应用程序发布到了使用WCF服务的同一个盒子上.

I have published my WCF project onto a server, i have also published an MVC application onto the same box which consumes the WCF services.

当尝试在我的MVC应用程序上登录时,这会使用wcf服务,但是我在浏览器上会收到此异常,

When trying login on my MVC application, this uses a wcf service, but i get this exception on the browser,

实体框架提供程序类型 'System.Data.Entity.SqlServer.SqlProviderServices, 在应用程序配置文件中注册了EntityFramework.SqlServer 用于具有不变名称'System.Data.SqlClient'的ADO.NET提供程序 无法加载.确保程序集限定名称为 使用该程序集,并且该程序集可用于正在运行的应用程序.

The Entity Framework provider type 'System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer' registered in the application config file for the ADO.NET provider with invariant name 'System.Data.SqlClient' could not be loaded. Make sure that the assembly-qualified name is used and that the assembly is available to the running application.

这是一个实体框架异常,但是我认为由于我的项目已经在开发环境中引用了EF,因此在部署服务项目之后,DLL也应该包含EF引用,但是我不确定为什么会出现此错误.

This is an entity framework exception, but i assume since my project already references EF in the dev environment, after deploying the service project, the DLLs should contain the EF reference also but I am not sure why I am getting this error.

我看到此消息是因为我打开了includeExceptionDetailInFaults="True"

I can see this message because I turned on the includeExceptionDetailInFaults="True"

推荐答案

@FranciscoGoldenstein说!您不需要在控制台应用程序中安装Entity Framework或任何其他任何东西,只需要添加对程序集EntityFramework.SqlServer.dll的引用.您可以将此程序集从使用实体框架的类库项目复制到LIB文件夹,并添加对它的引用.

@FranciscoGoldenstein saying ! You don't need to install Entity Framework in your Console application or whatever, you just need to add a reference to the assembly EntityFramework.SqlServer.dll. You can copy this assembly from the Class Library project that uses Entity Framework to a LIB folder and add a reference to it.

总结:

  • 类库应用程序:
    • 安装实体框架
    • 编写您的数据层代码
    • app.config文件具有与实体框架相关的所有配置,但连接字符串除外.
    • Class Library application:
      • Install Entity Framework
      • Write your data layer code
      • app.config file has all the configuration related to Entity Framework except for the connection string.
      • 添加对第一个项目的引用.
      • 添加对EntityFramework.SqlServer.dll的引用.
      • app.config/web.config具有连接字符串(请记住,配置条目的名称必须与DbContext类的名称相同.

      对我来说是工作!希望对您有帮助.

      it is work for me ! I hope it helps.

      也尝试此链接无法加载实体框架提供程序类型?

      这篇关于我该如何解决Entity Framework提供者异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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