近期了解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相关的程序集是否被引用,主要有两个:EntityFramework、EntityFramework.SqlServer (在这儿要注意两者的版本号是否一致,二者存在依赖关系,版本不一致的话,会报其他错)

在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;
}

不明所以,具体原因还是不清楚,这个方法也从来未被调用过,但是。。。好用了!

MVC4程序运行报错的更多相关文章

  1. MapReduce 程序运行报错 java.lang.ClassNotFoundException解决方法

    在创建自定义的Mapper时候,编译正确,但上传到集群执行时出现错误: 11/16/05 22:53:16 INFO mapred.JobClient: Task Id : attempt_20111 ...

  2. 小程序运行报错:errMsg: "request:fail url not in domain list"

    错误原因: 报错提示说请求的url不在域名列表里,应该是还没有配置服务器域名 解决方法: 可点击开发者工具右上角 详情-项目设置-不校验合法域名.web-view(业务域名).TLS 版本以及 HTT ...

  3. React Native 安卓 程序运行报错: React Native version mismatch(转载)

    这个问题已经得到解决,参照stackoverflow上的问题:https://stackoverflow.com/que...这个问题的原因就处在Android工程中app/build.gradle中 ...

  4. 小程序运行报错navigateTo:fail page "pages/warn/warn" is not found

    在index.js中配置触发时页面转发 wx.navigateTo({ url: '../warn/warn', }) 实际上触发时报错页面找不到 原因是页面路径没有在app.json里面没有定义过, ...

  5. eclipse android程序运行报错:Conversion to Dalvik format failed: Unable to execute dex:

    [2013-06-19 16:59:01 - Dex Loader] Unable to execute dex: Multiple dex files define Landroid/support ...

  6. javac编译出来的程序运行报错“错误: 找不到或无法加载主类”

    使用javac编译java文件生成class文件 >javac HelloWorld.java执行class文件>java HelloWorld 原因: 含有包名 解决办法: 按照包的结构 ...

  7. 运行netcore2.2程序是报错

    运行netcore2.2程序是报错 C:\myself\WuZhui\WuZhui\bin\Release\netcoreapp2.2>dotnet WuZhui.DLLError: An as ...

  8. python运行报错:urllib2.URLError: <urlopen error [Errno 10061] >

    Traceback (most recent call last): File "F:\adt-bundle-windows-x86_64-20140702\eclipse\workspac ...

  9. Heka 编译安装后 运行报错 panic: runtime error: cgo argument has Go pointer to Go pointer

    Heka 编译安装后 运行报错 panic: runtime error: cgo argument has Go pointer to Go pointer 解决办法: 1.  Start heka ...

随机推荐

  1. 通用addEventListener方法

    假设我们需要为一个<a id="aEle" href="http://www.baidu.com" />添加点击事件处理函数, 一般情况是这样的: ...

  2. python第一百零二天-----第十七周作业

    由于内容众多 直接使用 git 链接 : https://github.com/uge3/hosts_masg 主机管理WEB页面 使用 SQLALchemy 主机管理(8列) ip 用户表: 用户名 ...

  3. echars关系图

    <!DOCTYPE html> <html> <head> <meta name="viewport" content="wid ...

  4. 项目 插件 -下载- 使用,jar包-下载

    插件 -下载- 使用 BootCDN前端开源项目https://www.bootcdn.cn/all/ bootstrap:HTML.CSS 和 JS 框架    插件https://v3.bootc ...

  5. B - Modular Inverse

    The modular modular multiplicative inverse of an integer a modulo m is an integer x such that a-1≡x ...

  6. Android back键及backWebview模式跳转详解

    首先,来看一下关于Android home键和back键区别 back键 Android的程序无需刻意的去退出,当你一按下手机的back键的时候,系统会默认调用程序栈中最上层Activity的Dest ...

  7. HDU3949 XOR

    嘟嘟嘟 集训的时候发现自己不会线性基,就打算学一下. 这东西学了挺长时间,其实不是因为难,而是天天上午考试,下午讲题,结果晚上就开始颓了. 今天总算是有大块的时间好好学了一遍. 这里推荐menci大佬 ...

  8. HDU - 5078 水题

    题意:最大困难=距离 / 相邻时间 #include<cstring> #include<cstdio> #include<cmath> #define ll do ...

  9. metamascara学习导论

    研究了一段时间的metamascara终于有了一点起色,因为前段时间有一个小伙伴问了我一个问题,就是能不能将metamask嵌入到自己设计的网站中,在自己要进行交易的时候也会弹出一个页面来让用户确认这 ...

  10. Java面试题复习之Java基础

    1.面向对象的特征主要有哪些?   封装.继承.多态.抽象 2.final.finally.finalize的区别? final主要用于修饰类.方法.属性(变量)等. 通常被final修饰的类不能够被 ...