Entity Framework 4.1 Code First: Get all Entities with a specific base class
问题 I have a DbContext with set up different DbSet<T> s with all types that derive from the same base class: public class Foo : Entity { } public class Bar : Entity { } MyDbContext : DbContext { public DbSet<Foo> Foos { get; set; } public DbSet<Bar> Bars { get; set; } } Is it possible to get all entities which have the Entity base class in one query, like: DbContext.Set<Entity>(); // doesn't work I tried to introduce an explicit DbSet<Entity> to the DbContext, but that results in one big table