Missing Entity Framework Include(lambda) extension

.net entity-framework lambda

Question

The EF OjbectSet.Include(a => a.parent) extension is unavailable. I know I could add code to mimic it, but according to EntityFramework 4 upgraded to 5, lambda is not available it should be available. I have the using System.Data.Entity, and am upgraded to EF 5 in my main project.

Looking the metadata in Assembly 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);

There is no declaration for the lambda variant of Include here. I've checked and the file version is 4.0.30319.17929, as per Database first generation Entity Framework 5 System.Data.Entity vs EntityFramework . The project is generating a 4.5 assembly.

In case it's relevant, EntityFramework itself is not referenced in this assembly. It just has some data services, so it does include references to System.Data.Entity and the main data layer project.

Any ideas?

1
55
5/23/2017 11:47:05 AM

Accepted Answer

According to MSDN, the method is defined in the EntityFramework assembly. (in EntityFramework.dll)

You'll need to add a reference to the EntityFramework.dll DLL as well.

Afterwards, you'll need to make sure you're referencing the namespace:

using System.Data.Entity;

132
7/28/2017 7:39:40 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow