配置Entity Framework连接Sql Server出现的一个异常

    异常: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. See http://go.microsoft.com/fwlink/?LinkId=260882 for more information.

 

    方法1

      网上找到这样一个方法,在代码中添加:

      public void FixEfProviderServicesProblem()
      {
        //The Entity Framework provider type 'System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer'
        //for the 'System.Data.SqlClient' ADO.NET provider could not be loaded.
        //Make sure the provider assembly is available to the running application.
        //See http://go.microsoft.com/fwlink/?LinkId=260882 for more information.

        var instance = System.Data.Entity.SqlServer.SqlProviderServices.Instance;
      }

      本段代码并未使用;至于为什么会消除异常,还待深入了解。但这不是一个好的解决方法,它可能会引起另外一些问题。

 

     方法2

      在配置有Entity Framework的子项目中,有几个DLL如下:

      

      出现异常的原因主要是缺少了EntityFramework.DynamicFilters.dll、EntityFramework.SqlServer.dll、EntityFramework.SqlServer.xml。将这三个文件拷贝到主项目中,即可。

 

转载于:https://www.cnblogs.com/xuanxiaochen/p/5683660.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值