Reputation: 173
I know that in ef core you can generate migration script from one to next migrations. Lets say i have 5 migrations:
Migration3 and Migration4 already applied to database, and i want to generate script for Migrations 1, 2 and 5. Is it possible by using ef core tools? Or maybe there is some other tools?
Upvotes: 2
Views: 651
Reputation: 599
If I correctly understood your problem you want to deploy migrations to a database? You can use .Net Core CLI for that:
dotnet ef migrations script
This will generate a SQL script from this migration to the latest migration
dotnet ef migrations script xxx_name
You can also generate a SQL script from migration to the specified migration.
dotnet ef migrations script from_migration to_migration
Upvotes: 2
Reputation: 3290
Each migration builds on the previous and is generated assuming everything that came before it is already there. It would be very dangerous to apply the migrations out of order, or use something other than EF core to modify the portion of your database you are using it to manage. That being said, you can use the dotnet ef migrations script
command to generate a script moving from one migration to another. It will include all the migrations between them as well:
dotnet ef migrations script <FromMigration> <ToMigration> -o "FileName"
Upvotes: 0