Student 主表
StudentEducation 从表
建表的时候外键约束名写错了,不能数据库直接改
通过映射文件想要删掉外键重新生成
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey("FK_StudentEducation_Student_StudentTrackSignupId", "StudentEducation");
migrationBuilder.AddForeignKey(
name: "FK_StudentEducation_Student_StudentId",
table: "StudentEducation",
column: "StudentId",
principalTable: "Student",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
然后执行 EntityFrameworkCore\Update-Database -Context xx 就报错!
约束名称错误 这个问题已经排除了
希望能得到一些大佬的赐教,感谢感谢!!!
标签:StudentEducation,约束,migrationBuilder,请参阅,Student,StudentTrackSignupId,FK From: https://www.cnblogs.com/zdhk/p/18456495