I manually created a class
public class AddClientsTable : DbMigration, IMigrationMetadata { string IMigrationMetadata.Id { get { return "201611281757258_AddClientsTable"; } } string IMigrationMetadata.Source { get { return null; } } string IMigrationMetadata.Target { get { return "AddClientsTable-Migration"; } } public override void Up() { CreateTable("Clients", t => new { ClientId = t.Guid(name:"ClientId"), Name = t.String() }) .PrimaryKey( t => t.ClientId, "ClientId") .Index( t => t.ClientId, "PK_Clients", true); } public override void Down() { DropIndex("Clients", "PK_Clients"); DropTable("Clients"); } } and i want to apply it via code-first migrations from code like this :
var migration = new AddClientsTable(); migration.Up(); context.RunMigration(migration); which I stole from here but when I run the code I'm getting this exception :
Unable to cast object of type 'System.Data.Entity.Migrations.Model.CreateIndexOperation' to type 'System.Data.Entity.Migrations.Model.HistoryOperation'. HistoryOperation is the operation which updates __MigrationHistory table ? so How do I do that via code ?
Am I missing something or the EntityFrameowrk Update-Database command does more than what I'm aware of ?
MigrateDatabaseToLatestVersionmsdn.microsoft.com/en-us/library/… (sample here github.com/tym32167/arma3beclient/blob/master/src/…)