Linq-to-Entities Include method not found

jdiaz picture jdiaz · Mar 10, 2011 · Viewed 16.8k times · Source

I am using EF4 within a MVC3 application and I was looking for a way to view all my contacts within a given workgroup. In the controller I specified:

var wg = from w in _repo.Workgroups.Include("Contact").ToList();

but I get the following error:

'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?)

I though this method was built into EF4. Do I have enable it somehow?

Answer

BruceHill picture BruceHill · Sep 13, 2012

I was also getting this error and resolved it by adding the following reference:

using System.Data.Entity;