Inheritance and composite foreign keys - one part of the key in base class, the other part in derived class

后端 未结 3 1030
轮回少年
轮回少年 2020-12-11 01:21

I am having problems to create an Entity Framework Code-First mapping for the following sample database schema (in SQL Server):

3条回答
  •  佛祖请我去吃肉
    2020-12-11 01:43

    Not a solution, but a workaround (*): a nice choice is to use single Id columns (as ), usually auto-incremented, and providing database integrity using foreign keys, unique indexes, etc. More complex data integrity could be achieved with triggers, so maybe you could be heading that way, but you might leave that to the application business logic level, unless the application is really data-focused. But since you're using Entity Framework, it's probably safe to assume that this is not your case...?

    (*) as suggested by ivowiblo

提交回复
热议问题