[英]EntityFramework in .net6 "no entity type mapped to the table"
I've upgraded my code from .net3.1 to .net6 and now when I try to rebuild my database from scratch I'm getting this error:我已将代码从 .net3.1 升级到 .net6,现在当我尝试从头开始重建数据库时,出现此错误:
But as you can see in the same image, there is an entity configured to use that table!但正如您在同一张图片中看到的那样,有一个实体配置为使用该表!
the code in the migration that is failing is just the insertion of some data:迁移中失败的代码只是插入了一些数据:
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 }
});
}
How do I fix this error?如何修复此错误?
How can I specify the type or the column types in the operation?如何在操作中指定类型或列类型?
in my scenario, the solution was to delete the "schema: "dbo", argument. Having just this works:在我的场景中,解决方案是删除“模式:”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 }
});
}
I suppose .net6 doesn't like redundant arguments very much...我想.net6 非常不喜欢冗余的 arguments ......
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.