Using Foreign Key (FK) as Discriminator for Table-Per-Hierarchy (TPH)?

Most easily the solution lies in introducing an enum that is used as discriminator to represent the type. The post you mentioned clearly describes a FK cannot be used so you need to refactor that to something that can be applied. It requires some maintenance but since you also have to know the types that derive from your listitem, I don't see this as a major problem.

Other option you have would be to move away from TPH and use TablePerType. That way you don't actualy have to introduce an enum, but you will incurr a table for each derived listitem.

Thanks for your input Carlo. I should have mentioned that I discovered that TPT doesn't suffer from the issue, but it's not really an option in my scenario. Can you elaborate on the Enum approach?

How does that let me avoid adding another field to the DB to serve as a discriminator? The other problem is that this not and EF exclusive table, legacy applications still write to it (hence the trigger approach). – JimmyJames Nov 2 at 1:13.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions