asp.net-mvc-3 – 无法加载文件或程序集“System.Data.Entity”

我正在一个解决方案(一个笑话网站)工作。解决方案有2个项目:

>模型(C#类库)
> MVC 3空应用程序

我试图让我的观点列出数据库中的笑话,但是我收到以下错误

Could not load file or assembly ‘System.Data.Entity,Version=4.0.0.0,
Culture=neutral,PublicKeyToken=31bf3856ad364e35’ or one of its
dependencies. The system cannot find the file specified

从Error消息可以看出,我已经将System.Data.Entity添加到MVC 3应用程序的web.config中。

无论我做什么,我似乎无法修复错误!我已经为Entity类,HomeController和Index.cshtml添加了使用语句。

解决方法

要使用ASP.NET MVC 3使用外部实体框架模型(例如嵌入到DLL中),您必须:

>添加以下对MVC项目的引用:System.Data.Entity(版本4.0.0.0,Runtime v4.0.30319)
>在web.config添加以下行

< compilation debug="true" targetFramework="4.0">

  <assemblies>
    <add assembly="System.Data.Entity,Culture=neutral,PublicKeyToken=b77a5c561934e089" />
  </assemblies>
</compilation>

相关文章

这篇文章主要讲解了“WPF如何实现带筛选功能的DataGrid”,文...
本篇内容介绍了“基于WPF如何实现3D画廊动画效果”的有关知识...
Some samples are below for ASP.Net web form controls:(fr...
问题描述: 对于未定义为 System.String 的列,唯一有效的值...
最近用到了CalendarExtender,结果不知道为什么发生了错位,...
ASP.NET 2.0 page lifecyle ASP.NET 2.0 event sequence cha...