在ASP.Net MVC查看页面使用实体模型对象 [英] Using Entity Model Object in ASP.Net MVC View Page

查看:612
本文介绍了在ASP.Net MVC查看页面使用实体模型对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在ASP.Net MVC 3(剃刀视图)视图页面中使用一个实体框架对象,我pretty相信我这样做过。然而,无论出于何种原因,我不能让它在这个项目工作:

I'm trying to use an Entity Framework object in a view page for ASP.Net MVC 3 (Razor view) and I'm pretty sure I've done this before. However, for whatever reason I can't get it to work in this project:

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. 

Compiler Error Message: CS0012: The type 'System.Data.Objects.DataClasses.EntityObject' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

Source Error:

Line 1:  @model Data.Post

这是项目中的(我可以操纵控制器中的数据)来引用,但我不能让它在视图中工作。

That is referenced in the project (I can manipulate the data in the controller) but I can't get it to work in the view.

推荐答案

我希望你已包括

System.Data.Entity的

System.Data.Entity

到项目的参考。

现在


  1. 打开Web.config文件

  2. 转至组件部分:
    <编译调试=真targetFramework =4.0>
          <&集会GT;
                .....
          < /组件>
        < /编译>

地址:<添加组件=System.Data.Entity的,版本= 4.0.0.0,文化=中性公钥= b77a5c561934e089/>

希望工程!

这篇关于在ASP.Net MVC查看页面使用实体模型对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆