Is it possible to merge all migrations files into one ?
I created initial migration.
dotnet ef migrations add InitialMigration
When ever I have some model change I create new migration update.
But now I have too many migration update files. Is ti possible to merge all migration files to one ?
Off course drop database is not an option, I have to preserve data !
EF 6.X has a option
IgnoreChanges. That is the perfect fit for your scenario. But unfortunately it is not a feature available in EF core.
But there is a workaround.
Step 1 : Delete all the migration scripts in the Migrations folder.
Step 2 : In the package manager console : run
PM> Add-Migration InitialCreate
Step 3 : Delete both
Down() methods code. Before you do this, keep those methods saved elsewhere as we will need them again in step 5.
Step 4 : run:
It'll insert a new record into
Step 5 : After that fill the above migration script's (i.e.
Down() method from the content kept in a safe place from Step 3.
That is it. Now you have only 1 migration file :)
Note : EF core with Package manager console (PM) :Package Manager Console
One way to do that is removing all migration files physically and adding new one. If your migrations are in "Migrations" folder, you can simply delete it, otherwise you need to delete your "ModelSnapshot" file too. I think this approach can solve your issue.