Tuesday, March 20, 2012

System.Data.Entity.DbSet does not contain a definition for 'Where'

I came across the following error while trying to use a Linq query on a DbSet object in an ASP.NET MVC 4 Controller class;

System.Data.Entity.DbSet<MyApp.Models.MyModel>' does not contain a definition for 'Where' and no extension method 'Where' accepting a first argument of type System.Data.Entity.DbSet<MyApp.Models.MyModel>

The problem was resolved by adding  the System.Linq namespace to the controller. Where is an extension method and its definition lies in the System.Linq namespace.

No comments:

Post a Comment