Note that there are some explanatory texts on larger screens.

plurals
  1. POManaging EF Code First Migrations between Development and Production
    text
    copied!<p><strong>Very briefly:</strong></p> <p>I was implementing EF Migrations on an existing project built as Code First based on an article by <a href="http://www.ladislavmrnka.com/2012/03/ef-4-3-migrations-and-existing-database/" rel="nofollow">Ladislav Mrnka</a></p> <p>When implementing EF Migrations on a project that is already into production, how can Migration scripts be managed between updates applied to Development and then Scripts generated for Production? </p> <p>The reason I'm baffled is that the MigrationId generated for each script had a TimeStamp appended to it. In my migration attempts, I noticed that the entries recorded within the __MigrationHistory tables on dev and prod were different, thus raising the question, if the DB were to go through quite a few Migration Upgrades, then if ever a Downgrade was required for any reason, It would be very difficult to co-relate the exact MigrationId for creating the scripts using <code>update-database -script</code></p> <hr> <p>Very straight forward process where you create an <code>$InitialMigration</code> that creates the <code>__MigrationHistory</code> table. Then any changes to your Model are followed by any <code>update-database</code> to get the database <em>Migrated</em>. And this process cycles whenever you have a logically grouped batch of Model changes.</p> <p>A look into the <code>__MigrationHistory</code> table showed</p> <pre><code>+------------------------------------+-------------------------+------------------------------------------------------------------+----------------+ | MigrationId | CreatedOn | Model | ProductVersion | +------------------------------------+-------------------------+------------------------------------------------------------------+----------------+ | 000000000000000_BootstrapMigration | 2012-03-01 17:40:39.567 | 0x1F8B08000000400ECBD07601C49...HASH_TRUNCATED...CA7F54A20F50000 | 4.3.1 | | 201203011745335_AutomaticMigration | 2012-03-01 17:45:33.557 | 0x1F8B08000000400ECBD07601C49...HASH_TRUNCATED...F4AE3681EF50000 | 4.3.1 | +------------------------------------+-------------------------+------------------------------------------------------------------+----------------+ </code></pre>
 

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