删除迁移中的外键会引发两次
我正在尝试迁移 ASP.NET Core 6 + Entity Framework Core 项目。
迁移时,必须删除表的外键。
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Clients_Company",
table: "Clients");
}
在 Database.Migrate()
上下文构造函数中调用时,出现错误:
“FK_Clients_Company”不是约束。无法删除约束
同时,密钥本身可用(包括通过 sysobjects
中的请求定位)并被删除,事实证明 DropForeignKey
删除后第二次工作,但找不到密钥。
在其他任何地方都不会使用此键执行其他操作。
I'm trying to make a migration for an ASP.NET Core 6 + Entity Framework Core project.
In the migration, the foreign key of the table must be removed.
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Clients_Company",
table: "Clients");
}
When calling in the Database.Migrate()
context constructor, I get an error:
'FK_Clients_Company' is not a constraint. Could not drop constraint
At the same time, the key itself is available (including is located by a request in sysobjects
) and is deleted, it turns out thatDropForeignKey
works 2nd time after deletion and does not find the key.
No other manipulations are performed with this key anywhere else.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论