无法加载文件或程序集“System.Data.Entity" [英] Could not load file or assembly 'System.Data.Entity
问题描述
我在解决方案(一个笑话网站)中工作.该解决方案有 2 个项目:
I am working within a Solution (a jokes website). The Solution has 2 Projects:
- 模型(C# 类库)
- MVC 3 空应用程序
我试图让我的视图在数据库中列出笑话,但出现以下错误:
I am trying to get my view to list the Jokes in the Database, but I get the following error:
无法加载文件或程序集System.Data.Entity,版本=4.0.0.0,Culture=neutral, PublicKeyToken=31bf3856ad364e35' 或其中之一依赖关系.系统找不到指定的文件
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
正如您从错误消息中看到的,我已经将 System.Data.Entity 添加到 MVC 3 应用程序的 web.config.
As you can see from the Error message, I have already added the System.Data.Entity to the web.config of the MVC 3 application.
无论我做什么,我似乎都无法修复错误!我已将实体类的 using 语句添加到 HomeController 和 Index.cshtml.
No matter what I do, I seem to be unable to fix the error! I have added using statements for the Entity class, to the HomeController and the Index.cshtml.
推荐答案
要在 ASP.NET MVC 3 中使用外部实体框架模型(例如嵌入到 DLL 中),您必须:
To use an external Entity Framework model (embed in a DLL for example) with ASP.NET MVC 3 you must :
- 向您的 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, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</assemblies>
</compilation>
这篇关于无法加载文件或程序集“System.Data.Entity"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!