c# - ADO.NET Entity Framework 和 ASP.MVC 的组合有没有错?

标签 c# asp.net-mvc entity-framework

我有一个包含三个项目的解决方案。

  1. DomainModel(带有 ADO.NET Entity Framework 的 C# 库)
  2. DomainModelTest(业务逻辑单元测试)
  3. Web 应用程序(使用 DomainModel)

出于某种原因,如果我传递 DomainModel 中的任何对象,我什至无法带来 View ,甚至不是简单的对象。我收到以下错误:

有什么想法吗?

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=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

Source Error:

Line 146: Line 147:
[System.Runtime.CompilerServices.CompilerGlobalScopeAttribute()] Line 148: public class views_home_index_aspx : System.Web.Mvc.ViewPage, System.Web.SessionState.IRequiresSessionState, System.Web.IHttpHandler { Line 149:
Line 150: private static bool @__initialized;

我认为这可能会有所帮助,实际错误出现在 Default.aspx 文件中的以下行中:

public partial class _Default : Page
{
    public void Page_Load(object sender, System.EventArgs e)
    {
        // Change the current path so that the Routing handler can correctly interpret
        // the request, then restore the original path so that the OutputCache module
        // can correctly process the response (if caching is enabled).

        string originalPath = Request.Path;
        HttpContext.Current.RewritePath(Request.ApplicationPath, false);
        IHttpHandler httpHandler = new MvcHttpHandler();
        httpHandler.ProcessRequest(HttpContext.Current); //**HERE**
        HttpContext.Current.RewritePath(originalPath, false);
    }
}

最佳答案

尝试在 web.config 的 < assembly > 部分中添加引用。

关于c# - ADO.NET Entity Framework 和 ASP.MVC 的组合有没有错?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1501616/

相关文章:

c# - 如何在另一个文件更改时自动生成一个文件?

c# - 如何正确实现 IDisposable

c# - 在 GROUP BY MySQL 查询上读取 IDataReader

asp.net-mvc - 在 ASP.Net MVC 中,您如何创建将 javascript 和 css 放在它们应该去的地方的小部件?

asp.net - RenderBody() 和 RenderSection() 必须在每个子布局上?

c# - 如何在运行时使用 List<T> 上的 EditorFor() 更改 View

entity-framework - 检索导航属性会更改上下文

c# - 在控制台中检测 Ctrl + S

c# - 单事务中的数据库操作和API调用

c# - 如何使用 C# 和 Entity Framework 执行存储过程并忘记它?