divega wrote:
@popovks given the way you have defined your model this is expected behavior, i.e. in your model you have defined tree entity types that share a key property and the same inheritance hierarchy. This tells EF that all instances of Base, Address and Employee belong in the same "key space", and therefore an instance of Address and Employee with the same key values are conflicting. The behavior that you most likely you want can be achieved by instructing EF to ignore your base type altogether in the definition of the model using the Ignore method on DbModelBuilder. With that you can still take advantage of a common type to define common properties including a key Id property but EF will start reasoning about Address and Employee as defining separate key spaces.I wrote the following code
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Ignore<Base>();
base.OnModelCreating(modelBuilder);
}
but exception still occurs. Thanks for help