From fdf69c12c16a28043d33e00f1343006747750551 Mon Sep 17 00:00:00 2001 From: yangxiaodong Date: Wed, 28 Jun 2017 18:41:42 +0800 Subject: [PATCH] Add Migrations --- .../20170628102530_Init.Designer.cs | 67 +++++++++++++++++++ .../Migrations/20170628102530_Init.cs | 55 +++++++++++++++ .../Migrations/TestDbContextModelSnapshot.cs | 66 ++++++++++++++++++ .../TestDbContext.cs | 13 ++++ 4 files changed, 201 insertions(+) create mode 100644 test/DotNetCore.CAP.EntityFrameworkCore.Test/Migrations/20170628102530_Init.Designer.cs create mode 100644 test/DotNetCore.CAP.EntityFrameworkCore.Test/Migrations/20170628102530_Init.cs create mode 100644 test/DotNetCore.CAP.EntityFrameworkCore.Test/Migrations/TestDbContextModelSnapshot.cs create mode 100644 test/DotNetCore.CAP.EntityFrameworkCore.Test/TestDbContext.cs diff --git a/test/DotNetCore.CAP.EntityFrameworkCore.Test/Migrations/20170628102530_Init.Designer.cs b/test/DotNetCore.CAP.EntityFrameworkCore.Test/Migrations/20170628102530_Init.Designer.cs new file mode 100644 index 0000000..48d601f --- /dev/null +++ b/test/DotNetCore.CAP.EntityFrameworkCore.Test/Migrations/20170628102530_Init.Designer.cs @@ -0,0 +1,67 @@ +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using DotNetCore.CAP.EntityFrameworkCore.Test; + +namespace DotNetCore.CAP.EntityFrameworkCore.Test.Migrations +{ + [DbContext(typeof(TestDbContext))] + [Migration("20170628102530_Init")] + partial class Init + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { + modelBuilder + .HasAnnotation("ProductVersion", "1.1.2") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + modelBuilder.Entity("DotNetCore.CAP.Infrastructure.CapReceivedMessage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Added"); + + b.Property("Content"); + + b.Property("KeyName"); + + b.Property("LastRun"); + + b.Property("Retries"); + + b.Property("StateName") + .HasMaxLength(50); + + b.HasKey("Id"); + + b.ToTable("CapReceivedMessages"); + }); + + modelBuilder.Entity("DotNetCore.CAP.Infrastructure.CapSentMessage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Added"); + + b.Property("Content"); + + b.Property("KeyName"); + + b.Property("LastRun"); + + b.Property("Retries"); + + b.Property("StateName") + .HasMaxLength(50); + + b.HasKey("Id"); + + b.ToTable("CapSentMessages"); + }); + } + } +} diff --git a/test/DotNetCore.CAP.EntityFrameworkCore.Test/Migrations/20170628102530_Init.cs b/test/DotNetCore.CAP.EntityFrameworkCore.Test/Migrations/20170628102530_Init.cs new file mode 100644 index 0000000..4e6ad81 --- /dev/null +++ b/test/DotNetCore.CAP.EntityFrameworkCore.Test/Migrations/20170628102530_Init.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace DotNetCore.CAP.EntityFrameworkCore.Test.Migrations +{ + public partial class Init : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "CapReceivedMessages", + columns: table => new + { + Id = table.Column(nullable: false), + Added = table.Column(nullable: false), + Content = table.Column(nullable: true), + KeyName = table.Column(nullable: true), + LastRun = table.Column(nullable: false), + Retries = table.Column(nullable: false), + StateName = table.Column(maxLength: 50, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_CapReceivedMessages", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "CapSentMessages", + columns: table => new + { + Id = table.Column(nullable: false), + Added = table.Column(nullable: false), + Content = table.Column(nullable: true), + KeyName = table.Column(nullable: true), + LastRun = table.Column(nullable: false), + Retries = table.Column(nullable: false), + StateName = table.Column(maxLength: 50, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_CapSentMessages", x => x.Id); + }); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "CapReceivedMessages"); + + migrationBuilder.DropTable( + name: "CapSentMessages"); + } + } +} diff --git a/test/DotNetCore.CAP.EntityFrameworkCore.Test/Migrations/TestDbContextModelSnapshot.cs b/test/DotNetCore.CAP.EntityFrameworkCore.Test/Migrations/TestDbContextModelSnapshot.cs new file mode 100644 index 0000000..622471c --- /dev/null +++ b/test/DotNetCore.CAP.EntityFrameworkCore.Test/Migrations/TestDbContextModelSnapshot.cs @@ -0,0 +1,66 @@ +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using DotNetCore.CAP.EntityFrameworkCore.Test; + +namespace DotNetCore.CAP.EntityFrameworkCore.Test.Migrations +{ + [DbContext(typeof(TestDbContext))] + partial class TestDbContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { + modelBuilder + .HasAnnotation("ProductVersion", "1.1.2") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + modelBuilder.Entity("DotNetCore.CAP.Infrastructure.CapReceivedMessage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Added"); + + b.Property("Content"); + + b.Property("KeyName"); + + b.Property("LastRun"); + + b.Property("Retries"); + + b.Property("StateName") + .HasMaxLength(50); + + b.HasKey("Id"); + + b.ToTable("CapReceivedMessages"); + }); + + modelBuilder.Entity("DotNetCore.CAP.Infrastructure.CapSentMessage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Added"); + + b.Property("Content"); + + b.Property("KeyName"); + + b.Property("LastRun"); + + b.Property("Retries"); + + b.Property("StateName") + .HasMaxLength(50); + + b.HasKey("Id"); + + b.ToTable("CapSentMessages"); + }); + } + } +} diff --git a/test/DotNetCore.CAP.EntityFrameworkCore.Test/TestDbContext.cs b/test/DotNetCore.CAP.EntityFrameworkCore.Test/TestDbContext.cs new file mode 100644 index 0000000..5684692 --- /dev/null +++ b/test/DotNetCore.CAP.EntityFrameworkCore.Test/TestDbContext.cs @@ -0,0 +1,13 @@ +using Microsoft.EntityFrameworkCore; + +namespace DotNetCore.CAP.EntityFrameworkCore.Test +{ + public class TestDbContext : CapDbContext + { + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + { + var connectionString = ConnectionUtil.GetConnectionString(); + optionsBuilder.UseSqlServer(connectionString); + } + } +}