缺lessentity framework包含(lambda)扩展

EF OjbectSet.Include(a => a.parent)扩展名不可用。 我知道我可以添加代码来模仿它,但根据EntityFramework 4升级到5,lambda不可用,它应该是可用的。 我有using System.Data.Entity ,并在我的主要项目升级到EF 5。

查看程序集System.Data.Entity.dll,v4.0.0.0(C:\ Program Files(x86)\ Reference Assemblies \ Microsoft \ Framework.NETFramework \ v4.5 \ System.Data.Entity.dll)中的元数据。

 ... public ObjectQuery<System.Data.Common.DbDataRecord> GroupBy(string keys, string projection, params ObjectParameter[] parameters); public ObjectQuery<T> Include(string path); public ObjectQuery<T> Intersect(ObjectQuery<T> query); 

这里没有关于Include的lambda变体的声明。 我已经检查,文件版本是4.0.30319.17929,根据数据库第一代entity framework5 System.Data.Entity与EntityFramework 。 该项目正在生成一个4.5程序集。

在相关的情况下,这个程序集中没有引用EntityFramework本身。 它只是有一些数据服务,所以它包含对System.Data.Entity和主数据层项目的引用。

有任何想法吗?

根据MSDN ,该方法在EntityFramework程序集中定义。 (在EntityFramework.dll中)

您还需要添加对EntityFramework.dll DLL的引用。

之后,您需要确保您引用的是名称空间:

using System.Data.Entity;