[英]#Dotnet EF Core migration issue Foreign key constraint is incorrectly formed
While executing migration on the server (working proper on local) I am having the issue: 在服务器上执行迁移时(在本地正常工作),我遇到了以下问题:
Can't create table
hive
.无法创建表格
hive
。ApiaryHives
(errno: 150 "Foreign key constraint is incorrectly formed") ---> MySql.Data.MySqlClient.MySqlException (0x80004005): Can't create tablehive
.ApiaryHives
(错误号:150“外键约束ApiaryHives
不正确”)---> MySql.Data.MySqlClient.MySqlException(0x80004005):无法创建表hive
。ApiaryHives
(errno: 150 "Foreign key constraint is incorrectly formed")ApiaryHives
(错误号:150“外键约束ApiaryHives
不正确”)
Here is my migration file : 这是我的迁移文件:
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "ApiaryHives",
columns: table => new
{
ApiaryID = table.Column<int>(nullable: false),
HiveID = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ApiaryHives", x => new { x.ApiaryID, x.HiveID });
table.ForeignKey(
name: "FK_ApiaryHives_Apiary_ApiaryID",
column: x => x.ApiaryID,
principalTable: "Apiary",
principalColumn: "ID",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ApiaryHives_ApHives_HiveID",
column: x => x.HiveID,
principalTable: "ApHives",
principalColumn: "ID",
onDelete: ReferentialAction.Cascade);
});
}
除了我的表名,其他一切都很好,它在创建引用时包含后缀。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.