gpt4 book ai didi

entity-framework-core - "ef migrations add"总是在新迁移中重新创建外键

转载 作者:行者123 更新时间:2023-12-04 02:29:29 26 4
gpt4 key购买 nike

我有安装了 VS 2015 更新 1 的 RC1。

每当我尝试添加新迁移时,都会在 Up 方法中重新创建相同的外键集。这意味着它们被删除然后直接添加。

例如,当我添加迁移而不更改生成的任何模型时(当然,Down 方法中也会生成类似的内容):

protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId", table: "AspNetRoleClaims");
migrationBuilder.DropForeignKey(name: "FK_IdentityUserClaim<string>_ApplicationUser_UserId", table: "AspNetUserClaims");
migrationBuilder.DropForeignKey(name: "FK_IdentityUserLogin<string>_ApplicationUser_UserId", table: "AspNetUserLogins");
migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_IdentityRole_RoleId", table: "AspNetUserRoles");
migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_ApplicationUser_UserId", table: "AspNetUserRoles");
migrationBuilder.AlterColumn<string>(
name: "UserId",
table: "AspNetUserLogins",
nullable: false);
migrationBuilder.AlterColumn<string>(
name: "UserId",
table: "AspNetUserClaims",
nullable: false);
migrationBuilder.AlterColumn<string>(
name: "RoleId",
table: "AspNetRoleClaims",
nullable: false);
migrationBuilder.AddForeignKey(
name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId",
table: "AspNetRoleClaims",
column: "RoleId",
principalTable: "AspNetRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_IdentityUserClaim<string>_ApplicationUser_UserId",
table: "AspNetUserClaims",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_IdentityUserLogin<string>_ApplicationUser_UserId",
table: "AspNetUserLogins",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_IdentityUserRole<string>_IdentityRole_RoleId",
table: "AspNetUserRoles",
column: "RoleId",
principalTable: "AspNetRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_IdentityUserRole<string>_ApplicationUser_UserId",
table: "AspNetUserRoles",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}

这是完全没用的,看起来它总是发生在我的情况下。我在一个 aspnet5 应用程序和一个普通的控制台应用程序中尝试过这个。

最佳答案

这是一个已知问题,已经修复,rc2 即将修复。问题已被跟踪 here .

谢谢@firste。

关于entity-framework-core - "ef migrations add"总是在新迁移中重新创建外键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34082913/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com