Hi everyone,
I am trying to resolve a situation I ran into when implementing EF with my project.
I have absolved the table-per-type approach, in my case the ActionUpdate derives from the ActionHistory and that works fine.
What I am trying to achieve is to derive the ActionUpdate from the ActionHistory, and to have a navigation property at the ActionUpdate which will hold a collection of ActionUpdateDetail entities.
The problem starts with the inheritance: when I delete the ActionHistoryId from ActionUpdate, as per the MSDN sample, and then derive from ActionHistory and do the re-mapping, the ActionUpdateId automatically turns into non-PK property.
That behavior prevents me from mapping to the ActionUpdateDetail entity, as my new derived class does not contain the PK anymore :( I should map ActionUpdate.ActionUpdateId to ActionUpdateDetail.ActionUpdateid
My assumptions:
1) It is either not possible at all to achieve something like this, 2) I am just a stupid fart trying to do things the wrong way, 3) I am doomed :)
Any help with this issue is appreciated!
The picture depicts the entities I currently operate with.
The cause to the problem
I think it's important that I share with you the cause to my agony :)
I intuitively presumed that ActionUpdateDetail must map to ActionUpdate's Id, which was wrong.
Instead, it has to map to the ActionHistoryId property of ActionUpdate entity, because the ActionUpdate derives from the ActionHistory.
This little change caused the ActionUpdate table to lose it's Id column, i.e. it only contains the ActionHistoryId column. The reason for the existence of that single-column table is due to the fact that ActionHistory is an abstract entity, and I need something, i.e. ActionUpdate to hold the set of ActionUpdateDetail entities.
I hope this could help someone the same way I was helped :)