How to save derived type (TPT) in Entity Framework?
- by Peter Stegnar
I have problems with saving derived type (TPT) with Entity Framework to database.
Let's say I have base entity Animal and derived type Dog.
I want to save Dog entity.
I thought that I could do it like contex.AddToDogs(), but contex contain only base entity - Animal. So I can only save Animal object - contex.AddToAnimals().
I have also tried with contex.AddObject("Animals", dogInstance), but I get the following error: The member with identity 'NavigationProperty' does not exist in the metadata collection.
But I have add EntityReference to the "NavigationProperty".
So how to save derived type in EF?