【发布时间】:2014-02-10 16:39:43
【问题描述】:
public ActionResult Edit(int id)
{
using (var db = new BlogDataEntities())
{
return View(db.Blogs.Find(id));
}
}
我一直在使用这个 http://msdn.microsoft.com/en-gb/data/gg685489,但是在我的 IDE 中我无法在 db.Blogs 上获得方法 Find(),我正在使用 EntityFramework 4.1.0.0、MVC 3 和 .NET 4.0
我什至看过这个http://blogs.msdn.com/b/adonet/archive/2011/01/28/using-dbcontext-in-ef-feature-ctp5-part-3-finding-entities.aspx,但无法获取 Find() 方法。
知道为什么我无法在 db.Blogs 上获取 Find 方法吗?
【问题讨论】:
-
你添加了“ADO.NET DbContext Generator”吗?
-
感谢@BappiDatta,这是我的错误,我添加了“ADO.NET EntityObject Generator”而不是“ADO.NET DbContext Generator”。请发表您的评论作为答案,我会接受。
-
另外我认为我需要对 ADO.NET DbContext Generator、ADO.NET EntityObject Generator 和 ADO.NET Self-Tracking Entity Generator 之间的区别有一个深入的了解,你能写一篇文章吗?阅读以完全理解那些 3.
-
谢谢。我已将其发布为答案。
标签: asp.net-mvc-3 entity-framework c#-4.0 entity-framework-4.1