I have a .NET Core Project with lots of migrations in it. I also have the database (given to me and not generated with migrations on my pc). now
- When I try to add a migration I get an error that there are pending migrations and I first need to update database and I you can guess running update-database command gives me:
object ... already exists error
- If I remove database update-database command will generate the whole database however there are lots of data in the database that creating data with migrations would wipe them out.
I thought of generating data script from database, then creating database with migrations and then running the script, but the data script is very large and running the script have lots of other issues.
I just need to remove the old migrations but not unapplying them (as it would also remove my tables from database).
And also note that there are no _MigrationHistory Table in the database
dbo.__EFMigrationsHistorytable and add records manually. Note that I assume you use the latest EF Core (v3.1.x)