Note that there are some explanatory texts on larger screens.

plurals
  1. POMake EF4.3 Code First Migrations ignore pending migrations
    primarykey
    data
    text
    <p>I have a local instance of a database that I recently created using <code>DbContext.Database.Create()</code>, so the <code>__MigrationHistory</code> table exists with an <code>InitalCreate</code> entry that matches the code at the moment. </p> <p>Some code-based migrations exist in the Migrations folder, however. These will be run in our development and staging environments to bring those databases in line with the code. I don't need to apply them locally, however, since I created the database using the current code.</p> <p>I now need to make a change to the model and create the corresponding migration. But when I run <code>Add-Migration TestMigration</code>, I get the following error</p> <pre><code>Unable to generate an explicit migration because the following explicit migrations are pending: [201203271113060_AddTableX, 201203290856574_AlterColumnY] Apply the pending explicit migrations before attempting to generate a new explicit migration. </code></pre> <p>What should I do in this case? I can't point the Add-Migration tool at another environment because it's not guaranteed that version matches what I have locally. I want a migration that matches only the changes I've made.</p> <p>It seems I have a few options but none are ideal:</p> <ol> <li>Delete the other migrations from the Migrations folder, run the Add-Migration command, upgrade the database, then restore the old migrations. This is simple but seems a bit hackish.</li> <li>Revert to the version of the model in source control that the first migration was applied to, then build this and use it to create the database. Then get the latest version, apply all the migrations, then I'm ready to add my migration. This seems like a lot of effort!</li> <li>Create the migration manually.</li> </ol> <p>Does anyone have any suggestions about how to manage this?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload