开发者

EF with Inheritance with concrete classes

开发者 https://www.devze.com 2023-03-26 09:16 出处:网络
I have set of entities with some level of inheritance. abstract class A { ... } class B: A //Non abstract B

I have set of entities with some level of inheritance.

abstract class A
{
...
}

class B: A //Non abstract B
{...}

class C : B //Non abstract C

Since B and C are concrete classes i I tried setting up TPC inheritance strategy to get tables for B and C concrete classes in the database. However, because i did MapInheritedProperties() on B and C I get columns from table A duplicated in table C. How do i stop this? Am i using right inheritance strategy? Also, when i save changes to C(only) entity framework creates a row in table B for a row in C. Is there a way to p开发者_StackOverflow中文版revent this? I don't see anything wrong with my inheritance. Another approach which i tried is getting rid of the inheritance and use TPT for B and C and used Navigation property to link B and C. This approach worked but i am not convinced on why first approach didn't work.

0

精彩评论

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