我有三个项目的解决方案。ADO.NET实体框架和ASP.MVC的结合是错误的吗?
- 的DomainModel(C#库使用ADO.NET实体框架)
- DomainModelTest(单元测试业务逻辑)
- Web应用程序(使用的DomainModel)
出于某种原因,我甚至不能带来该视图是否通过DomainModel中的任何对象,甚至不是很简单。我得到以下错误:
任何想法?
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项目中添加了对System.Data.Entity的引用? – JasonTrue 2009-10-01 02:34:28
@Jason。是的,我做到了。我删除它,重新添加它,甚至检查版本,也尝试使用homecontroller中的语句。我甚至认为这是我的观点,所以我删除它们并重新创建它们。当他们没有引用由ado.net创建的对象enti fram都是好的,只要我尝试用户或任何其他对象,就会发生编译错误。谢谢。 – Geo 2009-10-01 02:38:35
在这里,我找到了答案如何解决编译问题 [http://stackoverflow.com/a/5129828/305197][1] [1]:http://stackoverflow.com/ a/5129828/305197 – 2012-11-20 22:30:48