Reputation: 842
As I'm progressing with my project I add more and more entities/properties/relationships. At the moment I have about 30 migration files, each describes a step that I added as a migration.
Is there a quick and elegant way to apply all those steps (what's specified in the Up method) into the context and get rid of those files?
Initially I did it manually, but it's too much now and I figured there has to be an automatic tool/command for this, no?
Cheers! J
Upvotes: 3
Views: 138
Reputation: 288
If I'm understanding you correctly, you'd like to be able to move from the initial database schema or an early database schema to the current database schema in one migratio?
You will need to exclude the current migration files from the project and create a new migration based on updating an empty or initial database schema.
You can pull an early version of your source code from your version control system and use it to build a new TEST database.
Once the TEST database is created, you can change the web.config of the most recent version of project's code to point to the TEST database.
Now you should be able to run the Add-Migration command against the old TEST database schema.
This should give you a plan that has all of the commands needed to update your database to the current version of the context.
The only problem will be that you will likely be missing seed data.
You may need to modify the execution your seed code if your database needs seeding.
Upvotes: 2