简体   繁体   中英

Upgraded .Net Core 3.1 to 5 Migration No Entity Type Mapped to Table

Upgraded our application from.Net Core 3.1 to 5.0.6, and everything was working using an existing database. If I drop the database and run the migrations I get this error:

There is no entity type mapped to the table 'UserClause' used in a data operation. Either add the corresponding entity type to the model or specify the column types in the data operation.

The UserClause table no longer exists it gets renamed in the migration that fails, but if this particular migration completed it would be the Agreement table, but it throws on this migration due to a missing entity type, which definitely doesn't exist either since this was originally run over a year ago.

Anyone know why the migration would be looking for an entity type, and how to resolve the issue? Doesn't seem like this should be checking for entities while it runs the migration.

Looks like in EF Core 5 that some of our migrations where there was a table rename had to have their update or insert statements moved to be after the rename of the table, otherwise you would get this error. Once they were after the table renaming and the table name for the update/insert were changed to the renamed table name everything worked.

In my case, i've to add the schema parameter to the InsertData function, like "dbo"

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