How to map Table per Type (TPT) inheritance in Entity designer?

Yes that is how Entity designer behaves. If you model your structure in the database and use Update model from database it will indeed be modeled as common associations beacuse EF doesn’t know yet that you want to model it as inheritance. You will get this:

enter image description here

You must manually modify this model to use TPT inheritance. First delete both relations. It will also remove navigation properties and you will get this:

enter image description here

Use Inheritance from toolbox (as described on previous screenshot) and draw a line from Film to Item and from Game to Item. Now you need to finish this model. The current model will not validate because ItemId is mapped in both parent and child entity. Delete ItemId from both Film and Game entities. You can also make Item entity Abstract and you will get this:

enter image description here

Leave a Comment