【发布时间】:2020-09-09 04:27:26
【问题描述】:
我正在尝试迁移数据库,但有一个我无法解决的问题。基本上我还必须迁移绑定到 Mysql 实现的现有迁移。这是问题的一个例子:
migrationBuilder.CreateTable(
name: "AspNetUserClaims",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
UserId = table.Column<string>(nullable: false),
ClaimType = table.Column<string>(nullable: true),
ClaimValue = table.Column<string>(nullable: true)
},
"MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn"
在每次迁移中,相同的问题都会引发错误,我在任何文档中都找不到如何为 Postgre 更改此问题。我猜这指定了主键自动生成方法。
附言
这是抛出的错误,因为我从 Pomelo.Mysql 切换到 ef core 的 npg.Postgre 数据库提供程序:
Error CS0103 The name 'MySqlValueGenerationStrategy' does not exist in the current context BingoAPI D:\Bingo\BingoAPI\Migrations\20200420230201_IdentityUser.cs 76 Active
【问题讨论】:
-
这个答案可能会有所帮助 - stackoverflow.com/questions/52365060/… 可能需要手动回顾您的迁移并为多个提供者添加代码:
标签: c# mysql postgresql asp.net-core entity-framework-core