Projektdateien hinzufügen.
This commit is contained in:
1 parent
0682df4d16
commit
749bdb5179
142 files changed
+63622
No files matched your search
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Design;
|
||||
using Microsoft.EntityFrameworkCore.Internal;
|
||||
|
||||
namespace FWLAZData
|
||||
{
|
||||
internal class ContextFactory : IDesignTimeDbContextFactory<LocalDbContext>
|
||||
{
|
||||
// public LocalDbContext CreateDbContext(string[] args) => new(new DbContextOptionsBuilder<LocalDbContext>().UseSqlite(args[0]).Options);
|
||||
public LocalDbContext CreateDbContext(string[] args) => new(new DbContextOptionsBuilder<LocalDbContext>().Options);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
using FWLAZData;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FWLAZData
|
||||
{
|
||||
public class DBManagement
|
||||
{
|
||||
public class ConnectionResult
|
||||
{
|
||||
public enum ConnectionStatus
|
||||
{
|
||||
ConnectionFailed,
|
||||
DatabaseMissing,
|
||||
UpdatesMissing,
|
||||
Successful,
|
||||
}
|
||||
|
||||
public ConnectionStatus Status { get; set; }
|
||||
public string? Details { get; set; }
|
||||
|
||||
public ConnectionResult(ConnectionStatus status)
|
||||
{
|
||||
Status = status;
|
||||
}
|
||||
public ConnectionResult(ConnectionStatus status, string details) : this(status)
|
||||
{
|
||||
Details = details;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
internal static void Migrate()
|
||||
{
|
||||
using (LocalDbContext db = new())
|
||||
{
|
||||
// Prüfen, ob Datenbank existiert, bevor EnsureCreated ausgeführt wird (EnsureCreated legt schon die benötigten Indizes an)
|
||||
var dbdir = Path.GetDirectoryName(LocalDbContext.DatabaseFile);
|
||||
if (dbdir != null && !Directory.Exists(dbdir)) Directory.CreateDirectory(dbdir);
|
||||
Console.Write("Applying migrations...");
|
||||
db.Database.Migrate();
|
||||
Console.WriteLine("Done");
|
||||
}
|
||||
}
|
||||
|
||||
public static ConnectionResult TestConnection()
|
||||
{
|
||||
try
|
||||
{
|
||||
using (LocalDbContext db = new())
|
||||
{
|
||||
if (!db.Database.CanConnect()) return new ConnectionResult(ConnectionResult.ConnectionStatus.DatabaseMissing); // CanConnect throws an exception if the server is not available and returns false if the database is missing
|
||||
if (db.Database.GetPendingMigrations().Count() > 0) return new ConnectionResult(ConnectionResult.ConnectionStatus.UpdatesMissing);
|
||||
return new ConnectionResult(ConnectionResult.ConnectionStatus.Successful);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ConnectionResult(ConnectionResult.ConnectionStatus.ConnectionFailed, ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public static void ConnectAndMigrate()
|
||||
{
|
||||
var ConnectionStatus = TestConnection();
|
||||
switch (ConnectionStatus.Status)
|
||||
{
|
||||
case ConnectionResult.ConnectionStatus.Successful:
|
||||
return;
|
||||
case ConnectionResult.ConnectionStatus.ConnectionFailed:
|
||||
throw new Exception($"Connection to database failed: {ConnectionStatus.Details}");
|
||||
case ConnectionResult.ConnectionStatus.DatabaseMissing:
|
||||
case ConnectionResult.ConnectionStatus.UpdatesMissing:
|
||||
Migrate();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FWLAZData.Data
|
||||
{
|
||||
public class Answer
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Text { get; set; } = null!;
|
||||
public bool IsCorrect { get; set; }
|
||||
|
||||
public virtual Question Question { get; set; } = null!;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FWLAZData.Data
|
||||
{
|
||||
public class Question
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Text { get; set; } = null!;
|
||||
public List<Answer> Answers { get; set; } = new List<Answer>();
|
||||
public virtual List<QuestionGroup> QuestionGroups { get; set; } = new();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FWLAZData.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// Eine Frage kann zu mehreren QuestionGroups gehören (bspw. hat Bronze die Fragen 1-16, Silber die Fragen 1-24 usw.)
|
||||
/// </summary>
|
||||
public class QuestionGroup
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; } = null!;
|
||||
public List<Question> Questions { get; set; } = new List<Question>();
|
||||
public virtual Quiz Quiz { get; set; } = null!;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FWLAZData.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// Beispiel:
|
||||
/// Quiz[0] = Feuerwehr Leistungsabzeichen Rheinland-Pfalz
|
||||
/// Quiz[1] = Feuerwehr Leistungsabzeichen Baden-Würtemberg
|
||||
/// </summary>
|
||||
public class Quiz
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; } = null!;
|
||||
|
||||
public List<QuestionGroup> Questiongroups { get; set; } = new();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.8" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.8">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.8" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.8">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Migrations\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,50 @@
|
||||
using FWLAZData.Data;
|
||||
using Microsoft.Data.Sqlite;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FWLAZData
|
||||
{
|
||||
public class LocalDbContext : DbContext
|
||||
{
|
||||
static string? ConnectionString;
|
||||
internal static string DatabaseFile { get; private set; } = "quiz.db";
|
||||
|
||||
|
||||
public DbSet<Quiz> Quiz { get; set; }
|
||||
public DbSet<QuestionGroup> QuestionGroup { get; set; }
|
||||
public DbSet<Question> Question { get; set; }
|
||||
public DbSet<Answer> Answers { get; set; }
|
||||
|
||||
public LocalDbContext() { }
|
||||
public LocalDbContext(DbContextOptions options) : base(options) { }
|
||||
|
||||
public static void SetConnectionString(string connectionstring)
|
||||
{
|
||||
var connstring = new SqliteConnectionStringBuilder(connectionstring);
|
||||
DatabaseFile = connstring.DataSource; // Benötigt um das Unterverzeichnis zu ermitteln und ggf. zu erstellen falls nicht vorhanden
|
||||
ConnectionString = connstring.ToString();
|
||||
}
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
if (!optionsBuilder.IsConfigured)
|
||||
{
|
||||
// Aktuell noch keine andere Möglichkeit gefunden, damit trotzdem dotnet ef migrations add, dotnet ef database update etc. ausgeführt werden kann.
|
||||
if (ConnectionString == null) SetConnectionString($"Data Source = {DatabaseFile}");
|
||||
optionsBuilder.UseSqlite(ConnectionString);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
+159
@@ -0,0 +1,159 @@
|
||||
// <auto-generated />
|
||||
using FWLAZData;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace FWLAZData.Migrations
|
||||
{
|
||||
[DbContext(typeof(LocalDbContext))]
|
||||
[Migration("20240830192533_Initial")]
|
||||
partial class Initial
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder.HasAnnotation("ProductVersion", "8.0.8");
|
||||
|
||||
modelBuilder.Entity("FWLAZData.Data.Answer", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<bool>("IsCorrect")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("QuestionId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Text")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("QuestionId");
|
||||
|
||||
b.ToTable("Answers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FWLAZData.Data.Question", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Text")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Question");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FWLAZData.Data.QuestionGroup", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("QuizId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("QuizId");
|
||||
|
||||
b.ToTable("QuestionGroup");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FWLAZData.Data.Quiz", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Quiz");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("QuestionQuestionGroup", b =>
|
||||
{
|
||||
b.Property<int>("QuestionGroupsId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("QuestionsId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.HasKey("QuestionGroupsId", "QuestionsId");
|
||||
|
||||
b.HasIndex("QuestionsId");
|
||||
|
||||
b.ToTable("QuestionQuestionGroup");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FWLAZData.Data.Answer", b =>
|
||||
{
|
||||
b.HasOne("FWLAZData.Data.Question", "Question")
|
||||
.WithMany("Answers")
|
||||
.HasForeignKey("QuestionId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Question");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FWLAZData.Data.QuestionGroup", b =>
|
||||
{
|
||||
b.HasOne("FWLAZData.Data.Quiz", "Quiz")
|
||||
.WithMany("Questiongroups")
|
||||
.HasForeignKey("QuizId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Quiz");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("QuestionQuestionGroup", b =>
|
||||
{
|
||||
b.HasOne("FWLAZData.Data.QuestionGroup", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("QuestionGroupsId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("FWLAZData.Data.Question", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("QuestionsId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FWLAZData.Data.Question", b =>
|
||||
{
|
||||
b.Navigation("Answers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FWLAZData.Data.Quiz", b =>
|
||||
{
|
||||
b.Navigation("Questiongroups");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace FWLAZData.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class Initial : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Question",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
Text = table.Column<string>(type: "TEXT", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Question", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Quiz",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
Name = table.Column<string>(type: "TEXT", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Quiz", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Answers",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
Text = table.Column<string>(type: "TEXT", nullable: false),
|
||||
IsCorrect = table.Column<bool>(type: "INTEGER", nullable: false),
|
||||
QuestionId = table.Column<int>(type: "INTEGER", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Answers", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Answers_Question_QuestionId",
|
||||
column: x => x.QuestionId,
|
||||
principalTable: "Question",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "QuestionGroup",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
Name = table.Column<string>(type: "TEXT", nullable: false),
|
||||
QuizId = table.Column<int>(type: "INTEGER", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_QuestionGroup", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_QuestionGroup_Quiz_QuizId",
|
||||
column: x => x.QuizId,
|
||||
principalTable: "Quiz",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "QuestionQuestionGroup",
|
||||
columns: table => new
|
||||
{
|
||||
QuestionGroupsId = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
QuestionsId = table.Column<int>(type: "INTEGER", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_QuestionQuestionGroup", x => new { x.QuestionGroupsId, x.QuestionsId });
|
||||
table.ForeignKey(
|
||||
name: "FK_QuestionQuestionGroup_QuestionGroup_QuestionGroupsId",
|
||||
column: x => x.QuestionGroupsId,
|
||||
principalTable: "QuestionGroup",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_QuestionQuestionGroup_Question_QuestionsId",
|
||||
column: x => x.QuestionsId,
|
||||
principalTable: "Question",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Answers_QuestionId",
|
||||
table: "Answers",
|
||||
column: "QuestionId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_QuestionGroup_QuizId",
|
||||
table: "QuestionGroup",
|
||||
column: "QuizId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_QuestionQuestionGroup_QuestionsId",
|
||||
table: "QuestionQuestionGroup",
|
||||
column: "QuestionsId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "Answers");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "QuestionQuestionGroup");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "QuestionGroup");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Question");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Quiz");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
// <auto-generated />
|
||||
using FWLAZData;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace FWLAZData.Migrations
|
||||
{
|
||||
[DbContext(typeof(LocalDbContext))]
|
||||
partial class LocalDbContextModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder.HasAnnotation("ProductVersion", "8.0.8");
|
||||
|
||||
modelBuilder.Entity("FWLAZData.Data.Answer", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<bool>("IsCorrect")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("QuestionId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Text")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("QuestionId");
|
||||
|
||||
b.ToTable("Answers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FWLAZData.Data.Question", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Text")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Question");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FWLAZData.Data.QuestionGroup", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("QuizId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("QuizId");
|
||||
|
||||
b.ToTable("QuestionGroup");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FWLAZData.Data.Quiz", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Quiz");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("QuestionQuestionGroup", b =>
|
||||
{
|
||||
b.Property<int>("QuestionGroupsId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("QuestionsId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.HasKey("QuestionGroupsId", "QuestionsId");
|
||||
|
||||
b.HasIndex("QuestionsId");
|
||||
|
||||
b.ToTable("QuestionQuestionGroup");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FWLAZData.Data.Answer", b =>
|
||||
{
|
||||
b.HasOne("FWLAZData.Data.Question", "Question")
|
||||
.WithMany("Answers")
|
||||
.HasForeignKey("QuestionId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Question");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FWLAZData.Data.QuestionGroup", b =>
|
||||
{
|
||||
b.HasOne("FWLAZData.Data.Quiz", "Quiz")
|
||||
.WithMany("Questiongroups")
|
||||
.HasForeignKey("QuizId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Quiz");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("QuestionQuestionGroup", b =>
|
||||
{
|
||||
b.HasOne("FWLAZData.Data.QuestionGroup", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("QuestionGroupsId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("FWLAZData.Data.Question", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("QuestionsId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FWLAZData.Data.Question", b =>
|
||||
{
|
||||
b.Navigation("Answers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FWLAZData.Data.Quiz", b =>
|
||||
{
|
||||
b.Navigation("Questiongroups");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Reference in new issue
Block a user