更新时间:2023-01-29 16:37:34
如果 dbo.Bingo_Bonus
表名称曾经更改过,或者如果外键关系中的任何列已更改,EF不会自动重命名外键约束以使其匹配。我有一个类似的问题,我不得不手动添加这样的行,因为 DropForeignKey()
函数实际上并没有删除应该被删除的键:
If the dbo.Bingo_Bonus
table name has ever changed, or if any of the columns in the foreign key relationships have changed, EF does not rename the foreign key constraints automatically to match. I had a similar problem and I had to manually add a line like this because the DropForeignKey()
function was not actually deleting the key it was supposed to:
Sql(@"ALTER TABLE [dbo].[MyTable] DROP CONSTRAINT [FK_dbo.Constraint_Name_From_Before_Table_Change]");