我是新来的实体框架和mvc。
我想了解Controller应该传递给视图的内容。
它应该是来自Models(MySolution.Models.Story)的类还是来自实体框架(MySolution.Story)的类。
问题是,如果我从实体框架中选择一个,那么DataTypes和html-helpers工作不正常。如果我选择从模型类的话,我无法从实体类转换成模型类,例如:我应该在控制器中使用实体框架类还是模型类?
TrendEntities TrendDB = new TrendEntities();
public ActionResult Details(int id) {
var Country = TrendDB.Countries.FirstOrDefault(c => c.CountryId ==id);
return View(Country);
}
从你的评论我发现我弄糟了框架和幕后发生的一切......现在情况正在好转。 – Stavros 2011-03-21 21:43:22