2012-03-23 15 views
1

を検出していません以下:dbmigrator私のようなものを持っている移行

namespace BilBasen.Data.Migrations 
{ 

    public class TestMigration : DbMigration 
    { 
     public override void Up() 
     { 

      CreateTable("TestMigrationTable", t => new { Id = t.Int(identity: true, nullable: false), Name = t.String(nullable: true) }); 
     } 

     public override void Down() 
     { 
      DropTable("TestMigrationTable"); 
     } 
    } 

    public class MigrateExecuter 
    { 
     public void UpdateToLatest() 
     { 
      var conf = new DbMigrationsConfiguration<LocalInstans2Context>(); 
      conf.AutomaticMigrationsEnabled = false; 
      conf.MigrationsNamespace = "BilBasen.Data.Migrations"; 
      conf.MigrationsAssembly = typeof(LocalInstans2Context).Assembly; 
      var migrator = new DbMigrator(conf); 


      migrator.Update(); 

     } 
    } 

    public class LocalInstans2Context : DbContext 
    { 

    } 
} 

の移行を検出していないマイグレー..

任意の提案を?

答えて

1

アンダー、

あなたはIMigrationMetadataがありません。試してください:

public class TestMigration : DbMigration, IMigrationMetadata 
{ 
    string IMigrationMetadata.Id 
    { 
     get { return "TestMigration "; } 
    } 

    string IMigrationMetadata.Source 
    { 
     get { return null; } 
    } 

    string IMigrationMetadata.Target 
    { 
     get { return "1"; } 
    } 


    public override void Up() 
    { 

     CreateTable("TestMigrationTable", t => new { Id = t.Int(identity: true, nullable: false), Name = t.String(nullable: true) }); 
    } 

    public override void Down() 
    { 
     DropTable("TestMigrationTable"); 
    } 
} 
関連する問題