EntityFramework5 and windows server2003

问题现象

在开发环境中(Win7 + MVC4 + EF5)系统能正常运行。

发布到Server2003后,访问系统报如下错误:

Method not found: 'Void System.Data.Objects.ObjectContextOptions.set_UseConsistentNullReferenceBehavior(Boolean)'.

 

原因分析

在开发环境中(Win7)已安装.net framewrok4.5,  EF5使用的是与framework 4.5配套的版本。

但server2003不支持framework4.5

解决办法

1,把项目的Target framework设置为4.0

2,引入Ef5 4.0版本的dll

 通过Library Package Manager Console加载EF5.0后,会在工程目录下生成EntityFramework.5.0.0文件夹。

 它的lib\下分别有net40,net45文件夹。

参考资料:

Method not found after deployment (System.Data.Objects).

.NET Framework System Requirements

原文地址:https://www.cnblogs.com/season2009/p/2825053.html