Rag*_*ock 6 c# entity-framework-core .net-6.0
我已将代码从 .net3.1 升级到 .net6,现在当我尝试从头开始重建数据库时,出现以下错误:
但正如您在同一张图中所看到的,有一个实体配置为使用该表!
迁移中失败的代码只是插入了一些数据:
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.InsertData(
schema: "dbo",
table: "PlannerGroup",
columns: new[] { "PlannerGroupId", "PlannerGroupName", "Position" },
values: new object[,]
{
{ 30, "Bread", 31 },
{ 31, "Drinks", 32 }
});
}
Run Code Online (Sandbox Code Playgroud)
我该如何修复这个错误?
如何在操作中指定类型或列类型?
在我的场景中,解决方案是删除“schema:”dbo”参数。这样就可以了:
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.InsertData(
table: "PlannerGroup",
columns: new[] { "PlannerGroupId", "PlannerGroupName", "Position" },
values: new object[,]
{
{ 30, "Bread", 31 },
{ 31, "Drinks", 32 }
});
}
Run Code Online (Sandbox Code Playgroud)
我想 .net6 不太喜欢多余的参数......
归档时间: |
|
查看次数: |
3285 次 |
最近记录: |