我在MVC3应用程序中使用EF4,并且正在寻找一种方法来查看给定工作组中的所有联系人。在控制器I规定:Linq-to-Entities包含方法未找到
var wg = from w in _repo.Workgroups.Include("Contact").ToList();
,但我得到了以下错误:
'System.Linq.IQueryable' does not contain a definition for 'Include' and no extension method 'Include' accepting a first argument of type 'System.Linq.IQueryable' could be found (are you missing a using directive or an assembly reference?)
我虽然这种方法被内置到EF4。我能以某种方式启用它吗?
在花费这么多时间试图弄清楚之后,难以置信的那么简单。谢谢@BruceHill – 2014-01-22 11:06:53
我也不敢相信这个解决方案有多容易,而且当时还没有人对这个问题提出过一年多的答案。所以,阿德里安,没问题。很高兴我能帮上忙。 – BruceHill 2014-02-06 10:44:40
这适用于Entity Framework 5及更高版本。 – 2014-04-21 16:19:50