Entity Framework - Invalid Column Name '*_ID"

后端 未结 15 1635
长发绾君心
长发绾君心 2020-11-29 21:30

I\'ve narrowed this down to some issue between Code First and Database first EF, but I\'m not sure how to fix it. I\'ll try to be as clear as I can, but I honestly am missin

15条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-29 21:44

    If you have this issue with a navigation property on the same table, you'll have to change the name of our property.

    For example :

    Table : PERSON
    Id
    AncestorId (with a foreign key which references Id named Parent) 
    

    You'll have to change AncestorId for PersonId.

    It seems that EF is trying to create a key ParentId because it couldn't find a table named Ancestor...

    EDIT : This is a fix for Database first !

提交回复
热议问题