Note that there are some explanatory texts on larger screens.

plurals
  1. POEF Code First Migrations: SetInitializer and Initialize
    text
    copied!<p>I am working on Code First Migration and Im trying work with code based migrations (Automatedmigration=false). What I can to do now it's:</p> <p>-Run Enable Migrations</p> <p>-Add migration Initial</p> <p>-Run migrations using "Update Database" (To create the migrationhistory table)</p> <p>-Make changes in my model</p> <p>-Execute Add Migration "changesInMyModel"</p> <p>Now what i am trying to do is be able to run all my migrations automatically. using something like:</p> <pre><code>[Test] public void UpdateDataModel() { Database.SetInitializer( new MigrateDatabaseToLatestVersion&lt;MyContext, MyConfiguration&gt;()); var dc = new MyContext(); dc.Database.Initialize(true); } </code></pre> <p>After to execute the test and go to the database i can't see any of my changes. What Can i do? advices are welcome!</p> <p>UPDATE: Myconfiguration class is using Automatedmigration=false.</p> <p>MyConfiguration class is public and visible outside of its parent project.</p> <p>I am not using any configuration in the app.config since that I am using Database.SetInitializer from the source code.</p> <p>Before to run my test MigrationHistory is created</p> <p>Running update database from package manager console the migrations run fine. </p> <p>UPDATE: I am running a version modified (using code based migration) of the example bellow: <a href="http://msdn.microsoft.com/en-us/data/jj591621.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/data/jj591621.aspx</a> , but the probleme is still there. - Enable migration - Add migration - Try SetInitializer and Initialize but nothing happen.</p> <p>UPDATE: - SetInitializer and Initialize working fine when Automatedmigration=true, the changes in the model are sync with the db. - Using the code bellow works. </p> <pre><code>new DbMigrator(new Configuration()).Update(); What should be the difference? </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