unterstüzung für MySql;

This commit is contained in:
2020-06-12 20:00:14 +02:00
parent dc19188392
commit 50fe69662d
7 changed files with 281 additions and 575 deletions

View File

@@ -1,277 +0,0 @@
// <auto-generated />
using System;
using MultipleChoiceTrainer.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace MultipleChoiceTrainer.Data.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("00000000000000_CreateIdentitySchema")]
partial class CreateIdentitySchema
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "3.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
{
b.Property<string>("Id")
.HasColumnType("nvarchar(450)");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.HasColumnType("nvarchar(256)")
.HasMaxLength(256);
b.Property<string>("NormalizedName")
.HasColumnType("nvarchar(256)")
.HasMaxLength(256);
b.HasKey("Id");
b.HasIndex("NormalizedName")
.IsUnique()
.HasName("RoleNameIndex")
.HasFilter("[NormalizedName] IS NOT NULL");
b.ToTable("AspNetRoles");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("ClaimType")
.HasColumnType("nvarchar(max)");
b.Property<string>("ClaimValue")
.HasColumnType("nvarchar(max)");
b.Property<string>("RoleId")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("AspNetRoleClaims");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b =>
{
b.Property<string>("Id")
.HasColumnType("nvarchar(450)");
b.Property<int>("AccessFailedCount")
.HasColumnType("int");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("nvarchar(max)");
b.Property<string>("Email")
.HasColumnType("nvarchar(256)")
.HasMaxLength(256);
b.Property<bool>("EmailConfirmed")
.HasColumnType("bit");
b.Property<bool>("LockoutEnabled")
.HasColumnType("bit");
b.Property<DateTimeOffset?>("LockoutEnd")
.HasColumnType("datetimeoffset");
b.Property<string>("NormalizedEmail")
.HasColumnType("nvarchar(256)")
.HasMaxLength(256);
b.Property<string>("NormalizedUserName")
.HasColumnType("nvarchar(256)")
.HasMaxLength(256);
b.Property<string>("PasswordHash")
.HasColumnType("nvarchar(max)");
b.Property<string>("PhoneNumber")
.HasColumnType("nvarchar(max)");
b.Property<bool>("PhoneNumberConfirmed")
.HasColumnType("bit");
b.Property<string>("SecurityStamp")
.HasColumnType("nvarchar(max)");
b.Property<bool>("TwoFactorEnabled")
.HasColumnType("bit");
b.Property<string>("UserName")
.HasColumnType("nvarchar(256)")
.HasMaxLength(256);
b.HasKey("Id");
b.HasIndex("NormalizedEmail")
.HasName("EmailIndex");
b.HasIndex("NormalizedUserName")
.IsUnique()
.HasName("UserNameIndex")
.HasFilter("[NormalizedUserName] IS NOT NULL");
b.ToTable("AspNetUsers");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("ClaimType")
.HasColumnType("nvarchar(max)");
b.Property<string>("ClaimValue")
.HasColumnType("nvarchar(max)");
b.Property<string>("UserId")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("AspNetUserClaims");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.Property<string>("LoginProvider")
.HasColumnType("nvarchar(128)")
.HasMaxLength(128);
b.Property<string>("ProviderKey")
.HasColumnType("nvarchar(128)")
.HasMaxLength(128);
b.Property<string>("ProviderDisplayName")
.HasColumnType("nvarchar(max)");
b.Property<string>("UserId")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.HasKey("LoginProvider", "ProviderKey");
b.HasIndex("UserId");
b.ToTable("AspNetUserLogins");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
{
b.Property<string>("UserId")
.HasColumnType("nvarchar(450)");
b.Property<string>("RoleId")
.HasColumnType("nvarchar(450)");
b.HasKey("UserId", "RoleId");
b.HasIndex("RoleId");
b.ToTable("AspNetUserRoles");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.Property<string>("UserId")
.HasColumnType("nvarchar(450)");
b.Property<string>("LoginProvider")
.HasColumnType("nvarchar(128)")
.HasMaxLength(128);
b.Property<string>("Name")
.HasColumnType("nvarchar(128)")
.HasMaxLength(128);
b.Property<string>("Value")
.HasColumnType("nvarchar(max)");
b.HasKey("UserId", "LoginProvider", "Name");
b.ToTable("AspNetUserTokens");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -1,146 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace MultipleChoiceTrainer.Data.Migrations
{
public partial class BusinessEntities : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Categories",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(nullable: true),
Description = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Categories", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Sections",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(nullable: true),
Description = table.Column<string>(nullable: true),
CategoryId = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Sections", x => x.Id);
table.ForeignKey(
name: "FK_Sections_Categories_CategoryId",
column: x => x.CategoryId,
principalTable: "Categories",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Questions",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Text = table.Column<string>(nullable: true),
SectionId = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Questions", x => x.Id);
table.ForeignKey(
name: "FK_Questions_Sections_SectionId",
column: x => x.SectionId,
principalTable: "Sections",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Answers",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Date = table.Column<DateTime>(nullable: false),
QuestionId = table.Column<int>(nullable: false),
Successfull = table.Column<bool>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Answers", x => x.Id);
table.ForeignKey(
name: "FK_Answers_Questions_QuestionId",
column: x => x.QuestionId,
principalTable: "Questions",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Choices",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
QuestionId = table.Column<int>(nullable: false),
Text = table.Column<string>(nullable: true),
IsTrue = table.Column<bool>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Choices", x => x.Id);
table.ForeignKey(
name: "FK_Choices_Questions_QuestionId",
column: x => x.QuestionId,
principalTable: "Questions",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Answers_QuestionId",
table: "Answers",
column: "QuestionId");
migrationBuilder.CreateIndex(
name: "IX_Choices_QuestionId",
table: "Choices",
column: "QuestionId");
migrationBuilder.CreateIndex(
name: "IX_Questions_SectionId",
table: "Questions",
column: "SectionId");
migrationBuilder.CreateIndex(
name: "IX_Sections_CategoryId",
table: "Sections",
column: "CategoryId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Answers");
migrationBuilder.DropTable(
name: "Choices");
migrationBuilder.DropTable(
name: "Questions");
migrationBuilder.DropTable(
name: "Sections");
migrationBuilder.DropTable(
name: "Categories");
}
}
}

View File

@@ -2,48 +2,45 @@
using System; using System;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using MultipleChoiceTrainer.Data; using MultipleChoiceTrainer.Data;
namespace MultipleChoiceTrainer.Data.Migrations namespace MultipleChoiceTrainer.Migrations
{ {
[DbContext(typeof(ApplicationDbContext))] [DbContext(typeof(ApplicationDbContext))]
[Migration("20200604185621_BusinessEntities")] [Migration("20200612175900_InitialSchemaMySql")]
partial class BusinessEntities partial class InitialSchemaMySql
{ {
protected override void BuildTargetModel(ModelBuilder modelBuilder) protected override void BuildTargetModel(ModelBuilder modelBuilder)
{ {
#pragma warning disable 612, 618 #pragma warning disable 612, 618
modelBuilder modelBuilder
.HasAnnotation("ProductVersion", "3.1.4") .HasAnnotation("ProductVersion", "3.1.5")
.HasAnnotation("Relational:MaxIdentifierLength", 128) .HasAnnotation("Relational:MaxIdentifierLength", 64);
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
{ {
b.Property<string>("Id") b.Property<string>("Id")
.HasColumnType("nvarchar(450)"); .HasColumnType("varchar(255) CHARACTER SET utf8mb4");
b.Property<string>("ConcurrencyStamp") b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken() .IsConcurrencyToken()
.HasColumnType("nvarchar(max)"); .HasColumnType("longtext CHARACTER SET utf8mb4");
b.Property<string>("Name") b.Property<string>("Name")
.HasColumnType("nvarchar(256)") .HasColumnType("varchar(256) CHARACTER SET utf8mb4")
.HasMaxLength(256); .HasMaxLength(256);
b.Property<string>("NormalizedName") b.Property<string>("NormalizedName")
.HasColumnType("nvarchar(256)") .HasColumnType("varchar(256) CHARACTER SET utf8mb4")
.HasMaxLength(256); .HasMaxLength(256);
b.HasKey("Id"); b.HasKey("Id");
b.HasIndex("NormalizedName") b.HasIndex("NormalizedName")
.IsUnique() .IsUnique()
.HasName("RoleNameIndex") .HasName("RoleNameIndex");
.HasFilter("[NormalizedName] IS NOT NULL");
b.ToTable("AspNetRoles"); b.ToTable("AspNetRoles");
}); });
@@ -52,18 +49,17 @@ namespace MultipleChoiceTrainer.Data.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int") .HasColumnType("int");
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("ClaimType") b.Property<string>("ClaimType")
.HasColumnType("nvarchar(max)"); .HasColumnType("longtext CHARACTER SET utf8mb4");
b.Property<string>("ClaimValue") b.Property<string>("ClaimValue")
.HasColumnType("nvarchar(max)"); .HasColumnType("longtext CHARACTER SET utf8mb4");
b.Property<string>("RoleId") b.Property<string>("RoleId")
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(450)"); .HasColumnType("varchar(255) CHARACTER SET utf8mb4");
b.HasKey("Id"); b.HasKey("Id");
@@ -75,53 +71,53 @@ namespace MultipleChoiceTrainer.Data.Migrations
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b => modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b =>
{ {
b.Property<string>("Id") b.Property<string>("Id")
.HasColumnType("nvarchar(450)"); .HasColumnType("varchar(255) CHARACTER SET utf8mb4");
b.Property<int>("AccessFailedCount") b.Property<int>("AccessFailedCount")
.HasColumnType("int"); .HasColumnType("int");
b.Property<string>("ConcurrencyStamp") b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken() .IsConcurrencyToken()
.HasColumnType("nvarchar(max)"); .HasColumnType("longtext CHARACTER SET utf8mb4");
b.Property<string>("Email") b.Property<string>("Email")
.HasColumnType("nvarchar(256)") .HasColumnType("varchar(256) CHARACTER SET utf8mb4")
.HasMaxLength(256); .HasMaxLength(256);
b.Property<bool>("EmailConfirmed") b.Property<bool>("EmailConfirmed")
.HasColumnType("bit"); .HasColumnType("tinyint(1)");
b.Property<bool>("LockoutEnabled") b.Property<bool>("LockoutEnabled")
.HasColumnType("bit"); .HasColumnType("tinyint(1)");
b.Property<DateTimeOffset?>("LockoutEnd") b.Property<DateTimeOffset?>("LockoutEnd")
.HasColumnType("datetimeoffset"); .HasColumnType("datetime(6)");
b.Property<string>("NormalizedEmail") b.Property<string>("NormalizedEmail")
.HasColumnType("nvarchar(256)") .HasColumnType("varchar(256) CHARACTER SET utf8mb4")
.HasMaxLength(256); .HasMaxLength(256);
b.Property<string>("NormalizedUserName") b.Property<string>("NormalizedUserName")
.HasColumnType("nvarchar(256)") .HasColumnType("varchar(256) CHARACTER SET utf8mb4")
.HasMaxLength(256); .HasMaxLength(256);
b.Property<string>("PasswordHash") b.Property<string>("PasswordHash")
.HasColumnType("nvarchar(max)"); .HasColumnType("longtext CHARACTER SET utf8mb4");
b.Property<string>("PhoneNumber") b.Property<string>("PhoneNumber")
.HasColumnType("nvarchar(max)"); .HasColumnType("longtext CHARACTER SET utf8mb4");
b.Property<bool>("PhoneNumberConfirmed") b.Property<bool>("PhoneNumberConfirmed")
.HasColumnType("bit"); .HasColumnType("tinyint(1)");
b.Property<string>("SecurityStamp") b.Property<string>("SecurityStamp")
.HasColumnType("nvarchar(max)"); .HasColumnType("longtext CHARACTER SET utf8mb4");
b.Property<bool>("TwoFactorEnabled") b.Property<bool>("TwoFactorEnabled")
.HasColumnType("bit"); .HasColumnType("tinyint(1)");
b.Property<string>("UserName") b.Property<string>("UserName")
.HasColumnType("nvarchar(256)") .HasColumnType("varchar(256) CHARACTER SET utf8mb4")
.HasMaxLength(256); .HasMaxLength(256);
b.HasKey("Id"); b.HasKey("Id");
@@ -131,8 +127,7 @@ namespace MultipleChoiceTrainer.Data.Migrations
b.HasIndex("NormalizedUserName") b.HasIndex("NormalizedUserName")
.IsUnique() .IsUnique()
.HasName("UserNameIndex") .HasName("UserNameIndex");
.HasFilter("[NormalizedUserName] IS NOT NULL");
b.ToTable("AspNetUsers"); b.ToTable("AspNetUsers");
}); });
@@ -141,18 +136,17 @@ namespace MultipleChoiceTrainer.Data.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int") .HasColumnType("int");
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("ClaimType") b.Property<string>("ClaimType")
.HasColumnType("nvarchar(max)"); .HasColumnType("longtext CHARACTER SET utf8mb4");
b.Property<string>("ClaimValue") b.Property<string>("ClaimValue")
.HasColumnType("nvarchar(max)"); .HasColumnType("longtext CHARACTER SET utf8mb4");
b.Property<string>("UserId") b.Property<string>("UserId")
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(450)"); .HasColumnType("varchar(255) CHARACTER SET utf8mb4");
b.HasKey("Id"); b.HasKey("Id");
@@ -164,19 +158,19 @@ namespace MultipleChoiceTrainer.Data.Migrations
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b => modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{ {
b.Property<string>("LoginProvider") b.Property<string>("LoginProvider")
.HasColumnType("nvarchar(128)") .HasColumnType("varchar(128) CHARACTER SET utf8mb4")
.HasMaxLength(128); .HasMaxLength(128);
b.Property<string>("ProviderKey") b.Property<string>("ProviderKey")
.HasColumnType("nvarchar(128)") .HasColumnType("varchar(128) CHARACTER SET utf8mb4")
.HasMaxLength(128); .HasMaxLength(128);
b.Property<string>("ProviderDisplayName") b.Property<string>("ProviderDisplayName")
.HasColumnType("nvarchar(max)"); .HasColumnType("longtext CHARACTER SET utf8mb4");
b.Property<string>("UserId") b.Property<string>("UserId")
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(450)"); .HasColumnType("varchar(255) CHARACTER SET utf8mb4");
b.HasKey("LoginProvider", "ProviderKey"); b.HasKey("LoginProvider", "ProviderKey");
@@ -188,10 +182,10 @@ namespace MultipleChoiceTrainer.Data.Migrations
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b => modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
{ {
b.Property<string>("UserId") b.Property<string>("UserId")
.HasColumnType("nvarchar(450)"); .HasColumnType("varchar(255) CHARACTER SET utf8mb4");
b.Property<string>("RoleId") b.Property<string>("RoleId")
.HasColumnType("nvarchar(450)"); .HasColumnType("varchar(255) CHARACTER SET utf8mb4");
b.HasKey("UserId", "RoleId"); b.HasKey("UserId", "RoleId");
@@ -203,18 +197,18 @@ namespace MultipleChoiceTrainer.Data.Migrations
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b => modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{ {
b.Property<string>("UserId") b.Property<string>("UserId")
.HasColumnType("nvarchar(450)"); .HasColumnType("varchar(255) CHARACTER SET utf8mb4");
b.Property<string>("LoginProvider") b.Property<string>("LoginProvider")
.HasColumnType("nvarchar(128)") .HasColumnType("varchar(128) CHARACTER SET utf8mb4")
.HasMaxLength(128); .HasMaxLength(128);
b.Property<string>("Name") b.Property<string>("Name")
.HasColumnType("nvarchar(128)") .HasColumnType("varchar(128) CHARACTER SET utf8mb4")
.HasMaxLength(128); .HasMaxLength(128);
b.Property<string>("Value") b.Property<string>("Value")
.HasColumnType("nvarchar(max)"); .HasColumnType("longtext CHARACTER SET utf8mb4");
b.HasKey("UserId", "LoginProvider", "Name"); b.HasKey("UserId", "LoginProvider", "Name");
@@ -225,17 +219,16 @@ namespace MultipleChoiceTrainer.Data.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int") .HasColumnType("int");
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<DateTime>("Date") b.Property<DateTime>("Date")
.HasColumnType("datetime2"); .HasColumnType("datetime(6)");
b.Property<int>("QuestionId") b.Property<int>("QuestionId")
.HasColumnType("int"); .HasColumnType("int");
b.Property<bool>("Successfull") b.Property<bool>("Successfull")
.HasColumnType("bit"); .HasColumnType("tinyint(1)");
b.HasKey("Id"); b.HasKey("Id");
@@ -248,14 +241,13 @@ namespace MultipleChoiceTrainer.Data.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int") .HasColumnType("int");
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("Description") b.Property<string>("Description")
.HasColumnType("nvarchar(max)"); .HasColumnType("longtext CHARACTER SET utf8mb4");
b.Property<string>("Name") b.Property<string>("Name")
.HasColumnType("nvarchar(max)"); .HasColumnType("longtext CHARACTER SET utf8mb4");
b.HasKey("Id"); b.HasKey("Id");
@@ -266,17 +258,16 @@ namespace MultipleChoiceTrainer.Data.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int") .HasColumnType("int");
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<bool>("IsTrue") b.Property<bool>("IsTrue")
.HasColumnType("bit"); .HasColumnType("tinyint(1)");
b.Property<int>("QuestionId") b.Property<int>("QuestionId")
.HasColumnType("int"); .HasColumnType("int");
b.Property<string>("Text") b.Property<string>("Text")
.HasColumnType("nvarchar(max)"); .HasColumnType("longtext CHARACTER SET utf8mb4");
b.HasKey("Id"); b.HasKey("Id");
@@ -289,14 +280,13 @@ namespace MultipleChoiceTrainer.Data.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int") .HasColumnType("int");
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<int>("SectionId") b.Property<int>("SectionId")
.HasColumnType("int"); .HasColumnType("int");
b.Property<string>("Text") b.Property<string>("Text")
.HasColumnType("nvarchar(max)"); .HasColumnType("longtext CHARACTER SET utf8mb4");
b.HasKey("Id"); b.HasKey("Id");
@@ -309,17 +299,16 @@ namespace MultipleChoiceTrainer.Data.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int") .HasColumnType("int");
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<int>("CategoryId") b.Property<int>("CategoryId")
.HasColumnType("int"); .HasColumnType("int");
b.Property<string>("Description") b.Property<string>("Description")
.HasColumnType("nvarchar(max)"); .HasColumnType("longtext CHARACTER SET utf8mb4");
b.Property<string>("Name") b.Property<string>("Name")
.HasColumnType("nvarchar(max)"); .HasColumnType("longtext CHARACTER SET utf8mb4");
b.HasKey("Id"); b.HasKey("Id");

View File

@@ -2,9 +2,9 @@
using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
namespace MultipleChoiceTrainer.Data.Migrations namespace MultipleChoiceTrainer.Migrations
{ {
public partial class CreateIdentitySchema : Migration public partial class InitialSchemaMySql : Migration
{ {
protected override void Up(MigrationBuilder migrationBuilder) protected override void Up(MigrationBuilder migrationBuilder)
{ {
@@ -47,12 +47,26 @@ namespace MultipleChoiceTrainer.Data.Migrations
table.PrimaryKey("PK_AspNetUsers", x => x.Id); table.PrimaryKey("PK_AspNetUsers", x => x.Id);
}); });
migrationBuilder.CreateTable(
name: "Categories",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Name = table.Column<string>(nullable: true),
Description = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Categories", x => x.Id);
});
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
name: "AspNetRoleClaims", name: "AspNetRoleClaims",
columns: table => new columns: table => new
{ {
Id = table.Column<int>(nullable: false) Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
RoleId = table.Column<string>(nullable: false), RoleId = table.Column<string>(nullable: false),
ClaimType = table.Column<string>(nullable: true), ClaimType = table.Column<string>(nullable: true),
ClaimValue = table.Column<string>(nullable: true) ClaimValue = table.Column<string>(nullable: true)
@@ -73,7 +87,7 @@ namespace MultipleChoiceTrainer.Data.Migrations
columns: table => new columns: table => new
{ {
Id = table.Column<int>(nullable: false) Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
UserId = table.Column<string>(nullable: false), UserId = table.Column<string>(nullable: false),
ClaimType = table.Column<string>(nullable: true), ClaimType = table.Column<string>(nullable: true),
ClaimValue = table.Column<string>(nullable: true) ClaimValue = table.Column<string>(nullable: true)
@@ -153,6 +167,94 @@ namespace MultipleChoiceTrainer.Data.Migrations
onDelete: ReferentialAction.Cascade); onDelete: ReferentialAction.Cascade);
}); });
migrationBuilder.CreateTable(
name: "Sections",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Name = table.Column<string>(nullable: true),
Description = table.Column<string>(nullable: true),
CategoryId = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Sections", x => x.Id);
table.ForeignKey(
name: "FK_Sections_Categories_CategoryId",
column: x => x.CategoryId,
principalTable: "Categories",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Questions",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Text = table.Column<string>(nullable: true),
SectionId = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Questions", x => x.Id);
table.ForeignKey(
name: "FK_Questions_Sections_SectionId",
column: x => x.SectionId,
principalTable: "Sections",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Answers",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Date = table.Column<DateTime>(nullable: false),
QuestionId = table.Column<int>(nullable: false),
Successfull = table.Column<bool>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Answers", x => x.Id);
table.ForeignKey(
name: "FK_Answers_Questions_QuestionId",
column: x => x.QuestionId,
principalTable: "Questions",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Choices",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
QuestionId = table.Column<int>(nullable: false),
Text = table.Column<string>(nullable: true),
IsTrue = table.Column<bool>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Choices", x => x.Id);
table.ForeignKey(
name: "FK_Choices_Questions_QuestionId",
column: x => x.QuestionId,
principalTable: "Questions",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Answers_QuestionId",
table: "Answers",
column: "QuestionId");
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "IX_AspNetRoleClaims_RoleId", name: "IX_AspNetRoleClaims_RoleId",
table: "AspNetRoleClaims", table: "AspNetRoleClaims",
@@ -162,8 +264,7 @@ namespace MultipleChoiceTrainer.Data.Migrations
name: "RoleNameIndex", name: "RoleNameIndex",
table: "AspNetRoles", table: "AspNetRoles",
column: "NormalizedName", column: "NormalizedName",
unique: true, unique: true);
filter: "[NormalizedName] IS NOT NULL");
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "IX_AspNetUserClaims_UserId", name: "IX_AspNetUserClaims_UserId",
@@ -189,12 +290,29 @@ namespace MultipleChoiceTrainer.Data.Migrations
name: "UserNameIndex", name: "UserNameIndex",
table: "AspNetUsers", table: "AspNetUsers",
column: "NormalizedUserName", column: "NormalizedUserName",
unique: true, unique: true);
filter: "[NormalizedUserName] IS NOT NULL");
migrationBuilder.CreateIndex(
name: "IX_Choices_QuestionId",
table: "Choices",
column: "QuestionId");
migrationBuilder.CreateIndex(
name: "IX_Questions_SectionId",
table: "Questions",
column: "SectionId");
migrationBuilder.CreateIndex(
name: "IX_Sections_CategoryId",
table: "Sections",
column: "CategoryId");
} }
protected override void Down(MigrationBuilder migrationBuilder) protected override void Down(MigrationBuilder migrationBuilder)
{ {
migrationBuilder.DropTable(
name: "Answers");
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "AspNetRoleClaims"); name: "AspNetRoleClaims");
@@ -210,11 +328,23 @@ namespace MultipleChoiceTrainer.Data.Migrations
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "AspNetUserTokens"); name: "AspNetUserTokens");
migrationBuilder.DropTable(
name: "Choices");
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "AspNetRoles"); name: "AspNetRoles");
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "AspNetUsers"); name: "AspNetUsers");
migrationBuilder.DropTable(
name: "Questions");
migrationBuilder.DropTable(
name: "Sections");
migrationBuilder.DropTable(
name: "Categories");
} }
} }
} }

View File

@@ -2,11 +2,10 @@
using System; using System;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using MultipleChoiceTrainer.Data; using MultipleChoiceTrainer.Data;
namespace MultipleChoiceTrainer.Data.Migrations namespace MultipleChoiceTrainer.Migrations
{ {
[DbContext(typeof(ApplicationDbContext))] [DbContext(typeof(ApplicationDbContext))]
partial class ApplicationDbContextModelSnapshot : ModelSnapshot partial class ApplicationDbContextModelSnapshot : ModelSnapshot
@@ -15,33 +14,31 @@ namespace MultipleChoiceTrainer.Data.Migrations
{ {
#pragma warning disable 612, 618 #pragma warning disable 612, 618
modelBuilder modelBuilder
.HasAnnotation("ProductVersion", "3.1.4") .HasAnnotation("ProductVersion", "3.1.5")
.HasAnnotation("Relational:MaxIdentifierLength", 128) .HasAnnotation("Relational:MaxIdentifierLength", 64);
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
{ {
b.Property<string>("Id") b.Property<string>("Id")
.HasColumnType("nvarchar(450)"); .HasColumnType("varchar(255) CHARACTER SET utf8mb4");
b.Property<string>("ConcurrencyStamp") b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken() .IsConcurrencyToken()
.HasColumnType("nvarchar(max)"); .HasColumnType("longtext CHARACTER SET utf8mb4");
b.Property<string>("Name") b.Property<string>("Name")
.HasColumnType("nvarchar(256)") .HasColumnType("varchar(256) CHARACTER SET utf8mb4")
.HasMaxLength(256); .HasMaxLength(256);
b.Property<string>("NormalizedName") b.Property<string>("NormalizedName")
.HasColumnType("nvarchar(256)") .HasColumnType("varchar(256) CHARACTER SET utf8mb4")
.HasMaxLength(256); .HasMaxLength(256);
b.HasKey("Id"); b.HasKey("Id");
b.HasIndex("NormalizedName") b.HasIndex("NormalizedName")
.IsUnique() .IsUnique()
.HasName("RoleNameIndex") .HasName("RoleNameIndex");
.HasFilter("[NormalizedName] IS NOT NULL");
b.ToTable("AspNetRoles"); b.ToTable("AspNetRoles");
}); });
@@ -50,18 +47,17 @@ namespace MultipleChoiceTrainer.Data.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int") .HasColumnType("int");
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("ClaimType") b.Property<string>("ClaimType")
.HasColumnType("nvarchar(max)"); .HasColumnType("longtext CHARACTER SET utf8mb4");
b.Property<string>("ClaimValue") b.Property<string>("ClaimValue")
.HasColumnType("nvarchar(max)"); .HasColumnType("longtext CHARACTER SET utf8mb4");
b.Property<string>("RoleId") b.Property<string>("RoleId")
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(450)"); .HasColumnType("varchar(255) CHARACTER SET utf8mb4");
b.HasKey("Id"); b.HasKey("Id");
@@ -73,53 +69,53 @@ namespace MultipleChoiceTrainer.Data.Migrations
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b => modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b =>
{ {
b.Property<string>("Id") b.Property<string>("Id")
.HasColumnType("nvarchar(450)"); .HasColumnType("varchar(255) CHARACTER SET utf8mb4");
b.Property<int>("AccessFailedCount") b.Property<int>("AccessFailedCount")
.HasColumnType("int"); .HasColumnType("int");
b.Property<string>("ConcurrencyStamp") b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken() .IsConcurrencyToken()
.HasColumnType("nvarchar(max)"); .HasColumnType("longtext CHARACTER SET utf8mb4");
b.Property<string>("Email") b.Property<string>("Email")
.HasColumnType("nvarchar(256)") .HasColumnType("varchar(256) CHARACTER SET utf8mb4")
.HasMaxLength(256); .HasMaxLength(256);
b.Property<bool>("EmailConfirmed") b.Property<bool>("EmailConfirmed")
.HasColumnType("bit"); .HasColumnType("tinyint(1)");
b.Property<bool>("LockoutEnabled") b.Property<bool>("LockoutEnabled")
.HasColumnType("bit"); .HasColumnType("tinyint(1)");
b.Property<DateTimeOffset?>("LockoutEnd") b.Property<DateTimeOffset?>("LockoutEnd")
.HasColumnType("datetimeoffset"); .HasColumnType("datetime(6)");
b.Property<string>("NormalizedEmail") b.Property<string>("NormalizedEmail")
.HasColumnType("nvarchar(256)") .HasColumnType("varchar(256) CHARACTER SET utf8mb4")
.HasMaxLength(256); .HasMaxLength(256);
b.Property<string>("NormalizedUserName") b.Property<string>("NormalizedUserName")
.HasColumnType("nvarchar(256)") .HasColumnType("varchar(256) CHARACTER SET utf8mb4")
.HasMaxLength(256); .HasMaxLength(256);
b.Property<string>("PasswordHash") b.Property<string>("PasswordHash")
.HasColumnType("nvarchar(max)"); .HasColumnType("longtext CHARACTER SET utf8mb4");
b.Property<string>("PhoneNumber") b.Property<string>("PhoneNumber")
.HasColumnType("nvarchar(max)"); .HasColumnType("longtext CHARACTER SET utf8mb4");
b.Property<bool>("PhoneNumberConfirmed") b.Property<bool>("PhoneNumberConfirmed")
.HasColumnType("bit"); .HasColumnType("tinyint(1)");
b.Property<string>("SecurityStamp") b.Property<string>("SecurityStamp")
.HasColumnType("nvarchar(max)"); .HasColumnType("longtext CHARACTER SET utf8mb4");
b.Property<bool>("TwoFactorEnabled") b.Property<bool>("TwoFactorEnabled")
.HasColumnType("bit"); .HasColumnType("tinyint(1)");
b.Property<string>("UserName") b.Property<string>("UserName")
.HasColumnType("nvarchar(256)") .HasColumnType("varchar(256) CHARACTER SET utf8mb4")
.HasMaxLength(256); .HasMaxLength(256);
b.HasKey("Id"); b.HasKey("Id");
@@ -129,8 +125,7 @@ namespace MultipleChoiceTrainer.Data.Migrations
b.HasIndex("NormalizedUserName") b.HasIndex("NormalizedUserName")
.IsUnique() .IsUnique()
.HasName("UserNameIndex") .HasName("UserNameIndex");
.HasFilter("[NormalizedUserName] IS NOT NULL");
b.ToTable("AspNetUsers"); b.ToTable("AspNetUsers");
}); });
@@ -139,18 +134,17 @@ namespace MultipleChoiceTrainer.Data.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int") .HasColumnType("int");
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("ClaimType") b.Property<string>("ClaimType")
.HasColumnType("nvarchar(max)"); .HasColumnType("longtext CHARACTER SET utf8mb4");
b.Property<string>("ClaimValue") b.Property<string>("ClaimValue")
.HasColumnType("nvarchar(max)"); .HasColumnType("longtext CHARACTER SET utf8mb4");
b.Property<string>("UserId") b.Property<string>("UserId")
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(450)"); .HasColumnType("varchar(255) CHARACTER SET utf8mb4");
b.HasKey("Id"); b.HasKey("Id");
@@ -162,19 +156,19 @@ namespace MultipleChoiceTrainer.Data.Migrations
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b => modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{ {
b.Property<string>("LoginProvider") b.Property<string>("LoginProvider")
.HasColumnType("nvarchar(128)") .HasColumnType("varchar(128) CHARACTER SET utf8mb4")
.HasMaxLength(128); .HasMaxLength(128);
b.Property<string>("ProviderKey") b.Property<string>("ProviderKey")
.HasColumnType("nvarchar(128)") .HasColumnType("varchar(128) CHARACTER SET utf8mb4")
.HasMaxLength(128); .HasMaxLength(128);
b.Property<string>("ProviderDisplayName") b.Property<string>("ProviderDisplayName")
.HasColumnType("nvarchar(max)"); .HasColumnType("longtext CHARACTER SET utf8mb4");
b.Property<string>("UserId") b.Property<string>("UserId")
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(450)"); .HasColumnType("varchar(255) CHARACTER SET utf8mb4");
b.HasKey("LoginProvider", "ProviderKey"); b.HasKey("LoginProvider", "ProviderKey");
@@ -186,10 +180,10 @@ namespace MultipleChoiceTrainer.Data.Migrations
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b => modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
{ {
b.Property<string>("UserId") b.Property<string>("UserId")
.HasColumnType("nvarchar(450)"); .HasColumnType("varchar(255) CHARACTER SET utf8mb4");
b.Property<string>("RoleId") b.Property<string>("RoleId")
.HasColumnType("nvarchar(450)"); .HasColumnType("varchar(255) CHARACTER SET utf8mb4");
b.HasKey("UserId", "RoleId"); b.HasKey("UserId", "RoleId");
@@ -201,18 +195,18 @@ namespace MultipleChoiceTrainer.Data.Migrations
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b => modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{ {
b.Property<string>("UserId") b.Property<string>("UserId")
.HasColumnType("nvarchar(450)"); .HasColumnType("varchar(255) CHARACTER SET utf8mb4");
b.Property<string>("LoginProvider") b.Property<string>("LoginProvider")
.HasColumnType("nvarchar(128)") .HasColumnType("varchar(128) CHARACTER SET utf8mb4")
.HasMaxLength(128); .HasMaxLength(128);
b.Property<string>("Name") b.Property<string>("Name")
.HasColumnType("nvarchar(128)") .HasColumnType("varchar(128) CHARACTER SET utf8mb4")
.HasMaxLength(128); .HasMaxLength(128);
b.Property<string>("Value") b.Property<string>("Value")
.HasColumnType("nvarchar(max)"); .HasColumnType("longtext CHARACTER SET utf8mb4");
b.HasKey("UserId", "LoginProvider", "Name"); b.HasKey("UserId", "LoginProvider", "Name");
@@ -223,17 +217,16 @@ namespace MultipleChoiceTrainer.Data.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int") .HasColumnType("int");
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<DateTime>("Date") b.Property<DateTime>("Date")
.HasColumnType("datetime2"); .HasColumnType("datetime(6)");
b.Property<int>("QuestionId") b.Property<int>("QuestionId")
.HasColumnType("int"); .HasColumnType("int");
b.Property<bool>("Successfull") b.Property<bool>("Successfull")
.HasColumnType("bit"); .HasColumnType("tinyint(1)");
b.HasKey("Id"); b.HasKey("Id");
@@ -246,14 +239,13 @@ namespace MultipleChoiceTrainer.Data.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int") .HasColumnType("int");
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("Description") b.Property<string>("Description")
.HasColumnType("nvarchar(max)"); .HasColumnType("longtext CHARACTER SET utf8mb4");
b.Property<string>("Name") b.Property<string>("Name")
.HasColumnType("nvarchar(max)"); .HasColumnType("longtext CHARACTER SET utf8mb4");
b.HasKey("Id"); b.HasKey("Id");
@@ -264,17 +256,16 @@ namespace MultipleChoiceTrainer.Data.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int") .HasColumnType("int");
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<bool>("IsTrue") b.Property<bool>("IsTrue")
.HasColumnType("bit"); .HasColumnType("tinyint(1)");
b.Property<int>("QuestionId") b.Property<int>("QuestionId")
.HasColumnType("int"); .HasColumnType("int");
b.Property<string>("Text") b.Property<string>("Text")
.HasColumnType("nvarchar(max)"); .HasColumnType("longtext CHARACTER SET utf8mb4");
b.HasKey("Id"); b.HasKey("Id");
@@ -287,14 +278,13 @@ namespace MultipleChoiceTrainer.Data.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int") .HasColumnType("int");
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<int>("SectionId") b.Property<int>("SectionId")
.HasColumnType("int"); .HasColumnType("int");
b.Property<string>("Text") b.Property<string>("Text")
.HasColumnType("nvarchar(max)"); .HasColumnType("longtext CHARACTER SET utf8mb4");
b.HasKey("Id"); b.HasKey("Id");
@@ -307,17 +297,16 @@ namespace MultipleChoiceTrainer.Data.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int") .HasColumnType("int");
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<int>("CategoryId") b.Property<int>("CategoryId")
.HasColumnType("int"); .HasColumnType("int");
b.Property<string>("Description") b.Property<string>("Description")
.HasColumnType("nvarchar(max)"); .HasColumnType("longtext CHARACTER SET utf8mb4");
b.Property<string>("Name") b.Property<string>("Name")
.HasColumnType("nvarchar(max)"); .HasColumnType("longtext CHARACTER SET utf8mb4");
b.HasKey("Id"); b.HasKey("Id");

View File

@@ -6,14 +6,22 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="3.1.4" /> <PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="3.1.5" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.1.4" /> <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.1.5" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="3.1.4" /> <PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="3.1.5" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="3.1.4" /> <PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="3.1.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.4" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.5">
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.4" /> <PrivateAssets>all</PrivateAssets>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.4" /> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.3" /> <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.3" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="3.1.1" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@@ -27,15 +27,28 @@ namespace MultipleChoiceTrainer
// This method gets called by the runtime. Use this method to add services to the container. // This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services) public void ConfigureServices(IServiceCollection services)
{ {
services.AddDbContext<ApplicationDbContext>(options => AddDbContext(services);
options.UseSqlServer(
Configuration.GetConnectionString("DefaultConnection")));
services.AddDefaultIdentity<IdentityUser>(options => options.SignIn.RequireConfirmedAccount = true) services.AddDefaultIdentity<IdentityUser>(options => options.SignIn.RequireConfirmedAccount = true)
.AddEntityFrameworkStores<ApplicationDbContext>(); .AddEntityFrameworkStores<ApplicationDbContext>();
services.AddControllersWithViews(); services.AddControllersWithViews();
services.AddRazorPages(); services.AddRazorPages();
} }
private void AddDbContext(IServiceCollection services)
{
var connectionString = Configuration.GetConnectionString("DefaultConnection");
if(connectionString.StartsWith("mysql://"))
{
var conStr = connectionString.Substring("mysql://".Length);
services.AddDbContext<ApplicationDbContext>(options => options.UseMySql(conStr));
}
else
{
services.AddDbContext<ApplicationDbContext>(options => options.UseSqlServer(connectionString));
}
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{ {