Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Missing Entity Framework Include(lambda) extension

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?

like image 259
shannon Avatar asked Oct 01 '13 19:10

shannon


1 Answers

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;

like image 83
Khan Avatar answered Sep 28 '22 18:09

Khan