saifuddinazhar
4/13/2018 - 6:57 AM

Database Migration

migrasi, step by step

 public override void Up()
  {
      AddColumn("dbo.Transact", "SalesmanID", c => c.Guid());
      CreateIndex("dbo.Transact", "SalesmanID");
      AddForeignKey("dbo.Transact", "SalesmanID", "dbo.Salesman", "ID");
      AlterColumn("dbo.TransactLine", "UnitID", c => c.Guid(nullable: false));
  }
  
  public override void Down()
  {
      DropForeignKey("dbo.Transact", "SalesmanID", "dbo.Salesman");
      DropIndex("dbo.Transact", new[] { "SalesmanID" });
      DropColumn("dbo.Transact", "SalesmanID");
      AlterColumn("dbo.TransactLine", "UnitID", c => c.Guid());
  }
migration
-    entities
-    if not exist :
        -    repository
        -    dbcontext (MaxiContext)
        -    seeder
- build/rebuild allowable, run not-allowable
        
sintag = add-migration <NamaMigrasi>

0) Check db conn being used, ensure its correct db
1) entity, etc
2) add-migration
3) build/rebuild to try whether error
4) if needed, commit local first
5) run
6) if work, sync