简体   繁体   English

.net6中的EntityFramework“没有实体类型映射到表”

[英]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.

相关问题 .NET6 中的实体框架 6.3 - Entity Framework 6.3 in .NET6 EntityFramework GroupBy实体类型 - EntityFramework GroupBy Entity Type 播种 Entity Framework Core 6 + .NET6 不起作用 - Seeding Entity Framework Core 6 + .NET6 not working .net6 实体框架中的默认可空参数 - Default Nullable Parameter in .net6 Entity Framework 获取EntityFramework的拦截中的实体类型 - Get Entity Type in Interception for EntityFramework Ef Core 3 实体类型 XOrder 不能映射到表,因为它派生自 Order Only 基本实体类型可以映射到表 - Ef Core 3 The entity type XOrder cannot be mapped to a table because it is derived from Order Only base entity types can be mapped to a table 实体类型“UserBase”无法映射到表,因为它派生自“User”。 只有基本实体类型可以映射到表 - The entity type 'UserBase' cannot be mapped to a table because it is derived from 'User'. Only base entity types can be mapped to a table 类型未映射的实体框架5.0 - The type not mapped entity framework 5.0 在Asp.Net Web Api中的EntityFramework中查找表对象实体以获得更新前的列的当前值 - Find Table Object Entity to get Current value of a Column before Updation in EntityFramework in Asp.Net Web Api 实体框架错误“实体类型未映射。” - Entity framework error "Entity type is not mapped."
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM