Reputation: 34152
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
object ... already exists error
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
Upvotes: 1
Views: 267
Reputation: 12022
If there is no __MigrationHistory
table in the database and you want to omit the migrations, you can also comment the Up
and Down
fields in the migration files and apply migration. It does not affect your database and only add migration record to __MigrationHistory
table.
Note: This problem might occur sometimes and using the approach above most probably fix the problem without affecting data. There are of course some other workarounds that can be applied for such a kind of problem.
Upvotes: 2