ASP.NET MVC4 & Entity Framework 6.0 IIS 部署出错解决方案
2017-07-03 14:26
381 查看
近期了解MVC4的时候弄了一个简单的小工程,使用Entity Framework作为Model,F5启动调试运行的时候没有问题,但是发布到IIS之后访问就报错
错误信息如下:
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的上下文代码CS文件(Model1.Context.cs)中添加这个方法
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;
}
不明所以,具体原因还是不清楚,这个方法也从来未被调用过,但是。。。好用了!
此解决方案还需要后续进行观测,毕竟修改的是根据数据库生成的文件。
还有一种方案我没有尝试,可以强制部署EntityFramework.SqlServer.dll这个文件到输出目录,有兴趣的可以尝试。
错误信息如下:
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的上下文代码CS文件(Model1.Context.cs)中添加这个方法
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;
}
不明所以,具体原因还是不清楚,这个方法也从来未被调用过,但是。。。好用了!
此解决方案还需要后续进行观测,毕竟修改的是根据数据库生成的文件。
还有一种方案我没有尝试,可以强制部署EntityFramework.SqlServer.dll这个文件到输出目录,有兴趣的可以尝试。
相关文章推荐
- ASP.NET MVC4 & Entity Framework 6.0 IIS 部署出错解决方案
- ASP.NET MVC4 & Entity Framework 6.0 IIS 部署出错解决方案
- Entity Framework 6.0 IIS 部署出错解决方案
- Win7部署asp.net网站,问题逐个突破<一>---Win7 IIS 部署网站,同局域网中电脑无法访问解决方案
- IIS Internal Server Error &IIS8中部署WCF服务出错:HTTP 错误 404.3 - Not Found
- Winform部署mshtml程序集出错的一个解决方案
- Install error "Exit Code: 6" or "Exit Code: 7" | Creative Adobe Production(安装Adobe产品时出错及解决方案)
- MOSS: Win 2008 & IIS 7 503 Service unavailable 错误解决方案
- 对路径" "的访问被拒绝XP中IIS下asp.net程序错误提示解决方案
- iis出错或不能运行的解决方案()
- Microsoft Visual C++ 6.0 (SP6)中 can not open include file "winresrc.h"问题的解决方案
- Win7 IIS 部署网站,同局域网中电脑无法访问解决方案
- 好书推荐:《IIS 6.0 Resource Kit》 & 《IIS 7.0 Resource Kit》 电子书,深入研究IIS的好资料
- 运行C-Free时出错,总是弹出窗口Control 'Message' has no parent window 的解决方案
- IIS 6.0部署ASP.NET MVC 2.0方法整理
- 针对windowsserver 创建iis站点访问出错的解决方案(HTTP 错误 500.19 - Internal Server Error)
- IIS7之下部署FluorineFx,找不到Fluorine.aspx文件的解决方案
- webservice 部署 IIS出错
- IIS运行不了ASP.NET的解决方案 & HTTP 500 - 内部服务器错误的解决方案
- Windows下,无法打开登录所请求的数据库DbName 。登录失败。 用户 'IIS APPPOOL/DefaultAppPool' 登录失败。 的解决方案