我有三個項目的解決方案。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