Entity Framework The ALTER TABLE statement conflicted with the FOREIGN KEY constraint

后端 未结 11 1805
傲寒
傲寒 2021-02-01 00:34

On updating database in Entity Framework , Code first Migration, I am getting this error:

The ALTER TABLE statement conflicted with the FOREIGN KEY constr

11条回答
  •  梦毁少年i
    2021-02-01 01:31

    I also received this message. The problem was that the test data in the db was incorrect. I didn't have validation on when I was testing and hence i had null values for IDs for fields that do not allow nulls. Once I fixed the data, the update-database command ran successfully.

提交回复
热议问题