How to implement inheritance Table-Per-Type in Entity Framework 4.3 via Code First approach?

前端 未结 1 1512
半阙折子戏
半阙折子戏 2021-01-15 03:28

I have this class hierarchy in code:

[Table(\"A\")]
public class A : IIdentification
{
    public int id { get; set; }
}

[Table(\"B\")]
public class B : A
{         


        
相关标签:
1条回答
  • 2021-01-15 04:08

    In mapped inheritance you don't have accessible navigation property to parent entity unless you want to model another relation. Inheritance is "is a" relation so B is A while FK is "has a" relation.

    Here you have a great walkthrough for TPT inheritance.

    0 讨论(0)
提交回复
热议问题