60

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?

Community
  • 1
  • 1
shannon
  • 8,664
  • 5
  • 44
  • 74
  • 17
    do you have `using System.Data.Entity` at the top of your code file? – Khan Oct 01 '13 at 19:48
  • Yup. I'll make that clearer in my comments above. Thanks Khan. – shannon Oct 01 '13 at 19:48
  • If you have a similar project loaded, can you tell me what metadata you see for "Include"? – shannon Oct 01 '13 at 19:49
  • 2
    ReSharper does not automatically recognize that you need using System.Data.Entity when building a lambda include, it must be manually added or added by some other process. – JabberwockyDecompiler Nov 13 '13 at 20:12
  • 1
    JabberwockyDecompiler - you saved the day there for me. again, trusutng resharper too much, didn't even think i needed a ref to `using System.Data.Entity`. turned out i sure did!! thanks again - +1 for your comment – jim tollan Nov 28 '13 at 12:42

1 Answers1

148

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;

Lucius
  • 2,794
  • 4
  • 20
  • 42
Khan
  • 17,904
  • 5
  • 47
  • 59
  • 2
    Oh, blarg. :) Thank you. I suppose it moved during an upgrade. – shannon Oct 01 '13 at 19:59
  • 24
    +1, this did not answer my issue, but the comments regarding adding a reference to `using System.Data.Entity` did!! – jim tollan Nov 28 '13 at 12:41
  • 2
    It's worth pointing out that there are different EntityFramework DLLs available. I searched in References and added the only one I could find, System.ServiceModel.DomainServices.EntityFramework (which didn't work). I eventually discovered that I needed to install the .NET EntityFramework NuGet package. – Ian Dec 24 '15 at 00:33