From 75cea9a04cd8884712795a789b12824fa0e81e48 Mon Sep 17 00:00:00 2001 From: Luke Latham <1622880+guardrex@users.noreply.github.com> Date: Mon, 7 Jan 2019 10:50:35 -0600 Subject: [PATCH] Add migrations to DP EntityFrameworkCoreSample (#6038) Per discussion: https://github.com/aspnet/Docs/issues/9864 --- .../EntityFrameworkCoreSample.csproj | 1 + ...19214311_AddDataProtectionKeys.Designer.cs | 40 +++++++++++++++++++ .../20181219214311_AddDataProtectionKeys.cs | 31 ++++++++++++++ .../DataProtectionKeyContextModelSnapshot.cs | 38 ++++++++++++++++++ 4 files changed, 110 insertions(+) create mode 100644 src/DataProtection/samples/EntityFrameworkCoreSample/Migrations/20181219214311_AddDataProtectionKeys.Designer.cs create mode 100644 src/DataProtection/samples/EntityFrameworkCoreSample/Migrations/20181219214311_AddDataProtectionKeys.cs create mode 100644 src/DataProtection/samples/EntityFrameworkCoreSample/Migrations/DataProtectionKeyContextModelSnapshot.cs diff --git a/src/DataProtection/samples/EntityFrameworkCoreSample/EntityFrameworkCoreSample.csproj b/src/DataProtection/samples/EntityFrameworkCoreSample/EntityFrameworkCoreSample.csproj index c6e228f0e0..b2a220acda 100644 --- a/src/DataProtection/samples/EntityFrameworkCoreSample/EntityFrameworkCoreSample.csproj +++ b/src/DataProtection/samples/EntityFrameworkCoreSample/EntityFrameworkCoreSample.csproj @@ -9,6 +9,7 @@ + diff --git a/src/DataProtection/samples/EntityFrameworkCoreSample/Migrations/20181219214311_AddDataProtectionKeys.Designer.cs b/src/DataProtection/samples/EntityFrameworkCoreSample/Migrations/20181219214311_AddDataProtectionKeys.Designer.cs new file mode 100644 index 0000000000..24b5c3e457 --- /dev/null +++ b/src/DataProtection/samples/EntityFrameworkCoreSample/Migrations/20181219214311_AddDataProtectionKeys.Designer.cs @@ -0,0 +1,40 @@ +// +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using EntityFrameworkCoreSample; + +namespace EntityFrameworkCoreSample.Migrations +{ + [DbContext(typeof(DataProtectionKeyContext))] + [Migration("20181219214311_AddDataProtectionKeys")] + partial class AddDataProtectionKeys + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "2.2.0") + .HasAnnotation("Relational:MaxIdentifierLength", 128) + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + modelBuilder.Entity("Microsoft.AspNetCore.DataProtection.EntityFrameworkCore.DataProtectionKey", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("FriendlyName"); + + b.Property("Xml"); + + b.HasKey("Id"); + + b.ToTable("DataProtectionKeys"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/DataProtection/samples/EntityFrameworkCoreSample/Migrations/20181219214311_AddDataProtectionKeys.cs b/src/DataProtection/samples/EntityFrameworkCoreSample/Migrations/20181219214311_AddDataProtectionKeys.cs new file mode 100644 index 0000000000..ac1f0ae29e --- /dev/null +++ b/src/DataProtection/samples/EntityFrameworkCoreSample/Migrations/20181219214311_AddDataProtectionKeys.cs @@ -0,0 +1,31 @@ +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace EntityFrameworkCoreSample.Migrations +{ + public partial class AddDataProtectionKeys : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "DataProtectionKeys", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), + FriendlyName = table.Column(nullable: true), + Xml = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_DataProtectionKeys", x => x.Id); + }); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "DataProtectionKeys"); + } + } +} diff --git a/src/DataProtection/samples/EntityFrameworkCoreSample/Migrations/DataProtectionKeyContextModelSnapshot.cs b/src/DataProtection/samples/EntityFrameworkCoreSample/Migrations/DataProtectionKeyContextModelSnapshot.cs new file mode 100644 index 0000000000..428ff36667 --- /dev/null +++ b/src/DataProtection/samples/EntityFrameworkCoreSample/Migrations/DataProtectionKeyContextModelSnapshot.cs @@ -0,0 +1,38 @@ +// +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using EntityFrameworkCoreSample; + +namespace EntityFrameworkCoreSample.Migrations +{ + [DbContext(typeof(DataProtectionKeyContext))] + partial class DataProtectionKeyContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "2.2.0") + .HasAnnotation("Relational:MaxIdentifierLength", 128) + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + modelBuilder.Entity("Microsoft.AspNetCore.DataProtection.EntityFrameworkCore.DataProtectionKey", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("FriendlyName"); + + b.Property("Xml"); + + b.HasKey("Id"); + + b.ToTable("DataProtectionKeys"); + }); +#pragma warning restore 612, 618 + } + } +}