Skip to content

Instantly share code, notes, and snippets.

@natemcmaster
Last active September 11, 2015 23:50
Show Gist options
  • Save natemcmaster/ad34901f065f8a76f656 to your computer and use it in GitHub Desktop.
Save natemcmaster/ad34901f065f8a76f656 to your computer and use it in GitHub Desktop.
npgsql
using System;
using System.Collections.Generic;
using Microsoft.Data.Entity.Migrations;
namespace Postgres.Migrations
{
public partial class MyFirstMigration : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Blog",
columns: table => new
{
Id = table.Column<int>(isNullable: false)
.Annotation("Npgsql:Serial", true)
},
constraints: table =>
{
table.PrimaryKey("PK_Blog", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Post",
columns: table => new
{
Id = table.Column<int>(isNullable: false)
.Annotation("Npgsql:Serial", true),
Title = table.Column<string>(isNullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Post", x => x.Id);
});
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable("Blog");
migrationBuilder.DropTable("Post");
}
}
}
using System;
using Microsoft.Data.Entity;
using Microsoft.Data.Entity.Infrastructure;
using Microsoft.Data.Entity.Metadata;
using Microsoft.Data.Entity.Migrations;
namespace Postgres.Migrations
{
[DbContext(typeof(BloggingContext))]
partial class MyFirstMigration
{
public override string Id
{
get { return "20150911233155_MyFirstMigration"; }
}
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
modelBuilder
.Annotation("ProductVersion", "7.0.0-beta7-15540");
modelBuilder.Entity("Postgres.Blog", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Key("Id");
});
modelBuilder.Entity("Postgres.Post", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("Title");
b.Key("Id");
});
}
}
}
using System;
using Microsoft.Data.Entity;
using Microsoft.Data.Entity.Infrastructure;
using Microsoft.Data.Entity.Metadata;
using Microsoft.Data.Entity.Migrations;
namespace Postgres.Migrations
{
[DbContext(typeof(BloggingContext))]
partial class BloggingContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
modelBuilder
.Annotation("ProductVersion", "7.0.0-beta7-15540");
modelBuilder.Entity("Postgres.Blog", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Key("Id");
});
modelBuilder.Entity("Postgres.Post", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("Title");
b.Key("Id");
});
}
}
}
IF NOT EXISTS (SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid=c.relnamespace WHERE c.relname='__MigrationHistory') THENCREATE TABLE "__MigrationHistory" (
"MigrationId" text NOT NULL,
"ProductVersion" text NOT NULL,
CONSTRAINT "PK_HistoryRow" PRIMARY KEY ("MigrationId")
);
END IF
;
CREATE TABLE "Blog" (
"Id" serial NOT NULL,
CONSTRAINT "PK_Blog" PRIMARY KEY ("Id")
);
CREATE TABLE "Post" (
"Id" serial NOT NULL,
"Title" text,
CONSTRAINT "PK_Post" PRIMARY KEY ("Id")
);
INSERT INTO "__MigrationHistory" ("MigrationId", "ProductVersion")
VALUES ('20150911233155_MyFirstMigration', '7.0.0-beta7-15540');;
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment