配置Entity Framework连接Sql Server出现的一个异常
2016-07-19 10:10
351 查看
异常: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如下:
![](https://oscdn.geek-share.com/Uploads/Images/Content/202007/29/ea810279ff612e72fc5a660230205b8e.png)
出现异常的原因主要是缺少了EntityFramework.DynamicFilters.dll、EntityFramework.SqlServer.dll、EntityFramework.SqlServer.xml。将这三个文件拷贝到主项目中,即可。
方法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如下:
![](https://oscdn.geek-share.com/Uploads/Images/Content/202007/29/ea810279ff612e72fc5a660230205b8e.png)
出现异常的原因主要是缺少了EntityFramework.DynamicFilters.dll、EntityFramework.SqlServer.dll、EntityFramework.SqlServer.xml。将这三个文件拷贝到主项目中,即可。
相关文章推荐
- SQL-基础学习4--聚集函数:AVG(),COUNT(),MAX(),MIN(),SUM();聚集不同值:DISTINCT
- oracle函数-cast
- Oracle查看数据库与数据库监听启动状态
- Oracle修改数据库连接数
- mysql 缓存
- 数据库连接池
- Oracle数据库常用操作sql语句
- sqlserver Split 开放写法有兴趣的学习一下
- tomcat使用memcached完成集群
- 必须知道的SQL编写技巧,多条件查询不拼字符串的写法
- SQLServer性能优化之 nolock,大幅提升数据库查询性能
- 数据库SQL优化大总结之 百万级数据库优化方案
- SQLServer控制用户访问权限表
- mybatis动态SQL语句
- SQL Server 2008 R2 Developer (x86, x64, ia64) – DVD (Chinese-Simplified)
- MySQL中的增删改
- mysql 定时备份bat脚本 ,方便小型服务简单快速备份mysql
- 未能加载文件或程序集“HelperSQL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null”
- 3# SQL函数 MERGE INTO
- 4#Oracle的instr函数使用