简体   繁体   中英

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:

错误

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:

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...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM