Include not available in inherited repostory

Go To


I have a repository like:

public class Repository<TEntity> : IRepository<TEntity> where TEntity : class, IEntity
    protected readonly IContext _db;

    public Repository(IContext context)
        _db = context;


Within methods in this class I can write statements with includes like:

var regionalAdmins = _db.Users.Include("Areas");

So then I wrote a repository which inherits from that one:

public class AreaRepository : Repository<Area>
    public AreaRepository(IContext context) : base (context)

    public new IEnumerable<Area> GetAreas()
        return _db.Users.Include("Areas");

At this level though I get the error:

System.Data.Entity.IDbSet' does not contain a definition for 'Include' and no extension method 'Include' accepting a first argument of type 'System.Data.Entity.IDbSet' could be found

Why would this be happening? I have the same context it just coming from the parent.

2012-04-03 21:39
by AnonyMouse


Include is an extension method declared in System.Data.Entity.DbExtensions. You're probably missing a using clause for the System.Data.Entity namespace.

2012-04-03 21:56
by Thomas Levesque