开发者

Table per Type Inhertiance and Data Generation Plans

开发者 https://www.devze.com 2023-01-01 14:33 出处:网络
I have an Entity Framework model using Table per Type Inheritance, but开发者_运维知识库 when I use a VS Data Generation Plan it produces duplicate keys in the child tables, which is a problem for EF.

I have an Entity Framework model using Table per Type Inheritance, but开发者_运维知识库 when I use a VS Data Generation Plan it produces duplicate keys in the child tables, which is a problem for EF. Does anyone know of a way to get this to work, so that the child tables do not have overlapping keys?


For anyone else trying to do this, I found a solution. You can change the generation type of foreign keys to interger, and then assign ranges. So for example, my parent table generates 40 records. Then each of my 4 child tables generates 10 records by setting a 1:4 ratio on each. Then, I set the ID value for the first table to 1-10, for the second 11-20, etc. This works perfectly.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号