Martin Martin - 5 months ago 11x
SQL Question

Entity Framework: Inheritance with same properties

I have a problem when I try to use Migrations in Entity Framework (Code First).

I have this models:

  • PERSON (int Id, string Name)

  • FRIEND : PERSON (string Document)

  • BESTFRIEND : PERSON (string Document)

  • BESTBESTFIEND : PERSON (string Address)

I'm trying to use the same property "Document" in FRIEND and BESTFRIEND, but not in BESBESTFRIEND so I don't want "Document" in root's class PERSON. When I try to make the Migration I get an error that says that I have an element created with the same key. How can I resolve this?


add [Column(Name = "Document")] to the two document properties