EF6 re-scaffold initial migration

c# entity-framework-6 npgsql

Question

Please assist me with one ef6 migrations difficulty. I often alter my model (since I don't fully comprehend schema). I've got two migrations. 1. earliest (ef6 generates this migration by my model) AddtionalInit 2. (some manual sql code that need to be executed after initialization)

I want to re-scaffold the first migration to apply modifications when I alter my model. I attempt to execute and migrate to -TargetMigration:0:

add-migration Initial -force

nonetheless, it throws an error.

Unable to generate an explicit migration because the following explicit migrations are pending: [201709290630180_Initial, 201709290631135_AdditionalInit]. Apply the pending explicit migrations before attempting to generate a new explicit migration

Without destroying AdditionalInit migration, can I scaffold Initial migration again?

Sorry about the English.

1
0
9/29/2017 7:07:04 AM

Popular Answer

Technically, you could make any more schema modifications using Raw SQL and the seed approach. Because the seed method runs every time the application launches, you would need to configure that Raw SQL to do a "check" to ensure that its modifications haven't previously been performed before starting.

Although it would probably be ideal to transfer it into its own migration after your model modifications are secure, this is a workable option if you had a lot of migration changes while the migration was still in progress.

0
2/15/2018 8:13:11 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow