Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I know this has been answered already - but just to add for 'historical purposes' and others that may be seeing this... </p> <p>The scenario that you have - supporting both <code>Production</code> and <code>Staging</code> backed with the same database - is a bit problematic from the Migrations standpoint. </p> <p>You can do away with migrations - drop the migrations table (the <code>__MigrationHistory</code>) - and synchronize things (see below posts for more) - but having two code-bases pointing to same Db means <code>one migration table</code> - and unless the codes are the same (migration-wise) it won't work. So the only solution would be to turn off migrations. </p> <p>However, there seems to be a light at the end of the tunnel. </p> <blockquote> <p>New builds coming from EF (EF6 pre-releases) have the <a href="http://entityframework.codeplex.com/wikipage?title=Migrations%20History%20Table%20Customization" rel="nofollow noreferrer">Code First Migrations History Table Customization</a>.</p> </blockquote> <p>I haven't managed time to play with that yet, but...<br> What that means is - simply put you can customize your <code>Configuration</code> and override the <code>IHistoryContextFactory</code>. <strong>That in turn allows you to rename the migration table</strong>. </p> <p>For more complex scenarios - like you have - that could be a solution </p> <blockquote> <p>note that it's not confirmed - but I'm thinking that they put it in there for those very reasons.</p> </blockquote> <p>A 'pseudo solution' would look like this... </p> <ul> <li>make two factories - for staging and production - each creates different 'migration table',</li> <li>each deployment - has its own migrations (in code) - and migration history in the database,</li> <li>you can manually tweak specific 'migration table' for e.g. staging - if needed - w/o compromising the other,</li> <li>make sure your database is 'similar enough' so that both codes/migrations can run side-by-side</li> </ul> <p>That could work, I think... </p> <hr/> <p><a href="https://stackoverflow.com/a/15397640/417747">How to Synchronize Db / Code - Summary</a><br> <a href="https://stackoverflow.com/a/10255051/417747">How to Synchronize Db / Code - Long Version</a></p>
 

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