I am using EF5 Code-first with entity classes like so:
public class Base {
public int Id { get; set; }
}
public class Derived : Base { // there are other derived types as well
}
and then I configure the derived entity as follows:
var config = new EntityTypeConfiguration<Base>();
config.Map<Derived>(m =>
{
m.MapInheritedProperties();
m.ToTable("derived");
});
DbModelBuilder modelBuilder = ...
modelBuilder.Configurations.Add(config);
In my application I then call:
new MyDbContext().Set<Derived>().First();
What is the expected behavior for this call?
Weirdly, I seem to be getting inconsistent behavior for hierarchies configured exactly the same way. Sometimes this fails because it tries to query "dbo.Base" and sometimes it correctly queries "dbo.Derived".