Skip to content

Instantly share code, notes, and snippets.

@hudo
Created October 30, 2012 11:56
Show Gist options
  • Save hudo/3979782 to your computer and use it in GitHub Desktop.
Save hudo/3979782 to your computer and use it in GitHub Desktop.
init migration
public partial class Init : DbMigration
{
public override void Up()
{
CreateTable(
"dbo.Products",
c => new
{
ProductId = c.Int(nullable: false, identity: true),
Name = c.Int(nullable: false),
Price = c.Decimal(nullable: false, precision: 18, scale: 2),
Category_CategoryId = c.Int(),
})
.PrimaryKey(t => t.ProductId)
.ForeignKey("dbo.Categories", t => t.Category_CategoryId)
.Index(t => t.Category_CategoryId);
CreateTable(
"dbo.Categories",
c => new
{
CategoryId = c.Int(nullable: false, identity: true),
Title = c.String(),
})
.PrimaryKey(t => t.CategoryId);
}
public override void Down()
{
DropIndex("dbo.Products", new[] { "Category_CategoryId" });
DropForeignKey("dbo.Products", "Category_CategoryId", "dbo.Categories");
DropTable("dbo.Categories");
DropTable("dbo.Products");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment