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

后端 未结 11 1830
傲寒
傲寒 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条回答
  •  遥遥无期
    2021-02-01 01:09

    Assuming your migrations are in correct order i.e. table associated with Foreign key will get created before the reference. Follow the following steps:

    1. Backup current database from SQL management studio (If required)
    2. Delete database from SQL management studio
    3. Type 'Update-Database'in Visual Studio 'Package Manager Console'

提交回复
热议问题