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:
-Run Enable Migrations
-Add migration Initial
-Run migrations using "Update Database" (To create the migrationhistory table)
-Make changes in my model
-Execute Add Migration "changesInMyModel"
Now what i am trying to do is be able to run all my migrations automatically. using something like:
[Test] 
public void UpdateDataModel()
{
 Database.SetInitializer(
 new MigrateDatabaseToLatestVersion<MyContext, MyConfiguration>());
 var dc = new MyContext();
 dc.Database.Initialize(true);
}
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!
UPDATE: Myconfiguration class is using Automatedmigration=false.
MyConfiguration class is public and visible outside of its parent project.
I am not using any configuration in the app.config since that I am using Database.SetInitializer from the source code.
Before to run my test MigrationHistory is created
Running update database from package manager console the migrations run fine.
UPDATE: I am running a version modified (using code based migration) of the example bellow: http://msdn.microsoft.com/en-us/data/jj591621.aspx , but the probleme is still there. - Enable migration - Add migration - Try SetInitializer and Initialize but nothing happen.
UPDATE: - SetInitializer and Initialize working fine when Automatedmigration=true, the changes in the model are sync with the db. - Using the code bellow works.
new DbMigrator(new Configuration()).Update(); What should be the difference?
    
dc.Database.Connection.ConnectionStringis what you're expecting.Add-Migrationnothingwillhappen if you try to do it from the code - is that what you're doing? To actually test it - you'd need to clean the Db first, then run migration / initializer from code. Other than that, the test should run ok.