InitialCode Commit

This commit is contained in:
Mueller Wayan
2025-09-07 19:06:43 +02:00
parent 887948bb02
commit d29e25992b
183 changed files with 82537 additions and 0 deletions
@@ -0,0 +1,20 @@
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using MTG_CollectionVerwaltung.Data.MTGCollection;
namespace MTG_CollectionVerwaltung.Data
{
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
: base(options)
{
}
}
public class ApplicationUser : IdentityUser
{
public bool MustChangePassword { get; set; }
}
}
@@ -0,0 +1,359 @@
namespace MTG_CollectionVerwaltung.Data
{
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace MTGCollection
{
public class MTGContext : DbContext
{
public MTGContext(DbContextOptions<MTGContext> options)
: base(options)
{
var conn = Database.GetDbConnection();
conn.Open();
// SQLite Funktion registrieren
var sqliteConn = (Microsoft.Data.Sqlite.SqliteConnection)conn;
sqliteConn.CreateFunction<string, string, int, int>("levenshtein", LevenshteinMinWordDistanceByLength);
}
public DbSet<Card> Cards { get; set; }
public DbSet<CardPrinting> CardPrintings { get; set; }
public DbSet<CardType> CardTypes { get; set; }
public DbSet<MTGType> Types { get; set; }
public DbSet<Set> Sets { get; set; }
public DbSet<CardCollection> CardCollections { get; set; }
public DbSet<Supertype> Supertypes { get; set; }
public DbSet<CardPrintingFts> CardPrintingsFts { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
// CardPrinting: zusammengesetzter Schlüssel
modelBuilder.Entity<CardPrinting>()
.HasIndex(cp => new { cp.CardId, cp.Lang })
.IsUnique(); // falls du weiterhin Eindeutigkeit auf CardId+Lang willst
modelBuilder.Entity<CardPrinting>()
.HasOne(cp => cp.Card)
.WithMany(c => c.Printings)
.HasForeignKey(cp => cp.CardId);
// CardType: zusammengesetzter Schlüssel
modelBuilder.Entity<CardType>()
.HasKey(ct => new { ct.CardId, ct.TypeId });
modelBuilder.Entity<CardType>()
.HasOne(ct => ct.Card)
.WithMany(c => c.CardTypes)
.HasForeignKey(ct => ct.CardId);
modelBuilder.Entity<CardType>()
.HasOne(ct => ct.Type)
.WithMany()
.HasForeignKey(ct => ct.TypeId);
// CardCollection: zusammengesetzter Schlüssel
modelBuilder.Entity<CardCollection>()
.HasKey(cc => new { cc.CardId, cc.UserId });
modelBuilder.Entity<CardCollection>()
.HasOne(cc => cc.Card)
.WithMany(c => c.Collections)
.HasForeignKey(cc => cc.CardId);
// Card -> Set
modelBuilder.Entity<Card>()
.HasOne(c => c.Set)
.WithMany(s => s.Cards)
.HasForeignKey(c => c.SetCode)
.HasPrincipalKey(s => s.SetCode);
// Card -> Supertype
modelBuilder.Entity<Card>()
.HasOne(c => c.SuperType)
.WithMany()
.HasForeignKey(c => c.SuperTypeId);
// Indizes
modelBuilder.Entity<Card>()
.HasIndex(c => c.CardName);
modelBuilder.Entity<CardCollection>()
.HasIndex(cc => cc.UserId);
modelBuilder.Entity<Card>()
.HasIndex(c => new { c.CollectorNumber, c.SetCode });
modelBuilder.Entity<CardPrinting>()
.HasIndex(c => c.Name);
modelBuilder.Entity<CardPrinting>()
.HasIndex(c => c.OracleText);
// Default Values
modelBuilder.Entity<Card>()
.Property(c => c.Foil)
.HasDefaultValue(false);
modelBuilder.Entity<Card>()
.Property(c => c.NonFoil)
.HasDefaultValue(false);
//Remove CaseSensitivity
modelBuilder.Entity<CardPrinting>()
.Property(c => c.Name)
.UseCollation("NOCASE");
modelBuilder.Entity<CardPrinting>()
.Property(c => c.OracleText)
.UseCollation("NOCASE");
modelBuilder.Entity<MTGType>()
.Property(c => c.TypeEn)
.UseCollation("NOCASE");
modelBuilder.Entity<MTGType>()
.Property(c => c.TypeDe)
.UseCollation("NOCASE");
modelBuilder.Entity<Supertype>()
.Property(c => c.TypeEn)
.UseCollation("NOCASE");
modelBuilder.Entity<Supertype>()
.Property(c => c.TypeDe)
.UseCollation("NOCASE");
modelBuilder.Entity<CardPrintingFts>(entity =>
{
entity.HasNoKey(); // Keyless, weil FTS rowid nicht als PK nutzbar
entity.ToView(null); // keine Migration/View erzeugen
entity.Property(e => e.Name);
entity.Property(e => e.OracleText);
entity.Property(e => e.FlavorText);
});
}
public static int LevenshteinMinWordDistanceByLength(string s, string t, int tolerance = 2)
{
if (string.IsNullOrEmpty(s)) return t?.Length ?? 0;
if (string.IsNullOrEmpty(t)) return s.Length;
if (s.Contains(t)) return 0;
var wordsS = s.Split(new[] { ' ', '-', '_', '`', '\'', ',' }, StringSplitOptions.RemoveEmptyEntries);
var wordsT = t.Split(new[] { ' ', '-', '_', '`', '\'', ',' }, StringSplitOptions.RemoveEmptyEntries);
int minDistance = int.MaxValue;
foreach (var ws in wordsS)
{
// nur Wörter in sinnvollem Längenbereich vergleichen
if (Math.Abs(ws.Length - t.Length) <= tolerance)
{
foreach (var wt in wordsT)
{
if (Math.Abs(ws.Length - wt.Length) <= tolerance)
{
int dist = Levenshtein(ws, wt);
if (dist < minDistance)
minDistance = dist;
}
}
}
}
return minDistance;
}
public static int Levenshtein(string s, string t)
{
if (string.IsNullOrEmpty(s)) return t?.Length ?? 0;
if (string.IsNullOrEmpty(t)) return s.Length;
int[,] d = new int[s.Length + 1, t.Length + 1];
for (int i = 0; i <= s.Length; i++) d[i, 0] = i;
for (int j = 0; j <= t.Length; j++) d[0, j] = j;
for (int i = 1; i <= s.Length; i++)
{
for (int j = 1; j <= t.Length; j++)
{
int cost = (s[i - 1] == t[j - 1]) ? 0 : 1;
d[i, j] = Math.Min(
Math.Min(d[i - 1, j] + 1, d[i, j - 1] + 1),
d[i - 1, j - 1] + cost);
}
}
return d[s.Length, t.Length];
}
public void EnsureFtsInitialized()
{
using var conn = (Microsoft.Data.Sqlite.SqliteConnection)Database.GetDbConnection();
conn.Open();
// Prüfen, ob FTS-Tabelle schon existiert
using var checkCmd = conn.CreateCommand();
checkCmd.CommandText = "SELECT name FROM sqlite_master WHERE type='table' AND name='CardPrintingsFTS';";
var exists = checkCmd.ExecuteScalar() != null;
if (!exists)
{
// FTS-Tabelle erstellen
using var createCmd = conn.CreateCommand();
createCmd.CommandText = @"
CREATE VIRTUAL TABLE CardPrintingsFTS
USING fts5(
Name,
OracleText,
FlavorText,
content='CardPrintings',
content_rowid='Id',
tokenize='trigram'
);
";
createCmd.ExecuteNonQuery();
}
}
public void RebuildCardPrintingsFts()
{
using var conn = (Microsoft.Data.Sqlite.SqliteConnection)Database.GetDbConnection();
conn.Open();
using var cmd = conn.CreateCommand();
cmd.CommandText = @"INSERT INTO CardPrintingsFTS(CardPrintingsFTS) VALUES('rebuild');";
cmd.ExecuteNonQuery();
}
}
public class Card
{
[Key]
public string Id { get; set; } = string.Empty;
[Required, MaxLength(10)]
public string SetCode { get; set; } = string.Empty;
[Required, MaxLength(100)]
public string CardName { get; set; } = string.Empty;
public string? CollectorNumber { get; set; }
public string? ManaCost { get; set; }
public bool Foil { get; set; }
public bool NonFoil { get; set; }
public string? Rarity { get; set; }
public string? Power { get; set; }
public string? Toughness { get; set; }
public int SuperTypeId { get; set; }
public int Cmc { get; set; }
public string? OtherFace { get; set; }
public Set Set { get; set; }
public Supertype SuperType { get; set; }
public ICollection<CardPrinting> Printings { get; set; } = new List<CardPrinting>();
public ICollection<CardType> CardTypes { get; set; } = new List<CardType>();
public ICollection<CardCollection> Collections { get; set; } = new List<CardCollection>();
}
public class CardPrinting
{
[Key]
public int Id { get; set; }
[Required, MaxLength(40)]
public string CardId { get; set; }
[Required, MaxLength(5)]
public string Lang { get; set; }
[Required, MaxLength(100)]
public string Name { get; set; }
public string? OracleText { get; set; }
public string? FlavorText { get; set; }
public string? ImageUriSmall { get; set; }
public string? ImageUriNormal { get; set; }
public string? ImageUriLarge { get; set; }
public Card Card { get; set; }
}
[Keyless]
public class CardPrintingFts
{
public string Name { get; set; }
public string? OracleText { get; set; }
public string? FlavorText { get; set; }
}
public class CardType
{
[Required]
public string CardId { get; set; }
[Required]
public int TypeId { get; set; }
public Card Card { get; set; }
public MTGType Type { get; set; }
}
public class MTGType
{
[Key]
public int TypeId { get; set; }
public string TypeEn { get; set; } = "";
public string TypeDe { get; set; } = "";
}
public class Supertype
{
[Key]
public int TypeId { get; set; }
public string TypeEn { get; set; } = "";
public string TypeDe { get; set; } = "";
}
public class Set
{
[Key, MaxLength(10)]
public string SetCode { get; set; }
[Required, MaxLength(50)]
public string SetName { get; set; }
public string SetIcon { get; set; }
public string SetType { get; set; }
public int CardCount { get; set; }
public DateTime ReleaseDate { get; set; }
public ICollection<Card> Cards { get; set; } = new List<Card>();
}
public class CardCollection
{
[Required]
public string CardId { get; set; }
[Required]
public string UserId { get; set; }
public int Count { get; set; }
public Card Card { get; set; }
}
}
}
@@ -0,0 +1,272 @@
// <auto-generated />
using System;
using MTG_CollectionVerwaltung.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace MTG_CollectionVerwaltung.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20250818150713_InitialCreate")]
partial class InitialCreate
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "8.0.19");
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
{
b.Property<string>("Id")
.HasColumnType("TEXT");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("TEXT");
b.Property<string>("Name")
.HasMaxLength(256)
.HasColumnType("TEXT");
b.Property<string>("NormalizedName")
.HasMaxLength(256)
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("NormalizedName")
.IsUnique()
.HasDatabaseName("RoleNameIndex");
b.ToTable("AspNetRoles", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("ClaimType")
.HasColumnType("TEXT");
b.Property<string>("ClaimValue")
.HasColumnType("TEXT");
b.Property<string>("RoleId")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("AspNetRoleClaims", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b =>
{
b.Property<string>("Id")
.HasColumnType("TEXT");
b.Property<int>("AccessFailedCount")
.HasColumnType("INTEGER");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("TEXT");
b.Property<string>("Email")
.HasMaxLength(256)
.HasColumnType("TEXT");
b.Property<bool>("EmailConfirmed")
.HasColumnType("INTEGER");
b.Property<bool>("LockoutEnabled")
.HasColumnType("INTEGER");
b.Property<DateTimeOffset?>("LockoutEnd")
.HasColumnType("TEXT");
b.Property<string>("NormalizedEmail")
.HasMaxLength(256)
.HasColumnType("TEXT");
b.Property<string>("NormalizedUserName")
.HasMaxLength(256)
.HasColumnType("TEXT");
b.Property<string>("PasswordHash")
.HasColumnType("TEXT");
b.Property<string>("PhoneNumber")
.HasColumnType("TEXT");
b.Property<bool>("PhoneNumberConfirmed")
.HasColumnType("INTEGER");
b.Property<string>("SecurityStamp")
.HasColumnType("TEXT");
b.Property<bool>("TwoFactorEnabled")
.HasColumnType("INTEGER");
b.Property<string>("UserName")
.HasMaxLength(256)
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("NormalizedEmail")
.HasDatabaseName("EmailIndex");
b.HasIndex("NormalizedUserName")
.IsUnique()
.HasDatabaseName("UserNameIndex");
b.ToTable("AspNetUsers", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("ClaimType")
.HasColumnType("TEXT");
b.Property<string>("ClaimValue")
.HasColumnType("TEXT");
b.Property<string>("UserId")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("AspNetUserClaims", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.Property<string>("LoginProvider")
.HasMaxLength(128)
.HasColumnType("TEXT");
b.Property<string>("ProviderKey")
.HasMaxLength(128)
.HasColumnType("TEXT");
b.Property<string>("ProviderDisplayName")
.HasColumnType("TEXT");
b.Property<string>("UserId")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("LoginProvider", "ProviderKey");
b.HasIndex("UserId");
b.ToTable("AspNetUserLogins", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
{
b.Property<string>("UserId")
.HasColumnType("TEXT");
b.Property<string>("RoleId")
.HasColumnType("TEXT");
b.HasKey("UserId", "RoleId");
b.HasIndex("RoleId");
b.ToTable("AspNetUserRoles", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.Property<string>("UserId")
.HasColumnType("TEXT");
b.Property<string>("LoginProvider")
.HasMaxLength(128)
.HasColumnType("TEXT");
b.Property<string>("Name")
.HasMaxLength(128)
.HasColumnType("TEXT");
b.Property<string>("Value")
.HasColumnType("TEXT");
b.HasKey("UserId", "LoginProvider", "Name");
b.ToTable("AspNetUserTokens", (string)null);
});
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
}
}
}
@@ -0,0 +1,222 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace MTG_CollectionVerwaltung.Migrations
{
/// <inheritdoc />
public partial class InitialCreate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "AspNetRoles",
columns: table => new
{
Id = table.Column<string>(type: "TEXT", nullable: false),
Name = table.Column<string>(type: "TEXT", maxLength: 256, nullable: true),
NormalizedName = table.Column<string>(type: "TEXT", maxLength: 256, nullable: true),
ConcurrencyStamp = table.Column<string>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetRoles", x => x.Id);
});
migrationBuilder.CreateTable(
name: "AspNetUsers",
columns: table => new
{
Id = table.Column<string>(type: "TEXT", nullable: false),
UserName = table.Column<string>(type: "TEXT", maxLength: 256, nullable: true),
NormalizedUserName = table.Column<string>(type: "TEXT", maxLength: 256, nullable: true),
Email = table.Column<string>(type: "TEXT", maxLength: 256, nullable: true),
NormalizedEmail = table.Column<string>(type: "TEXT", maxLength: 256, nullable: true),
EmailConfirmed = table.Column<bool>(type: "INTEGER", nullable: false),
PasswordHash = table.Column<string>(type: "TEXT", nullable: true),
SecurityStamp = table.Column<string>(type: "TEXT", nullable: true),
ConcurrencyStamp = table.Column<string>(type: "TEXT", nullable: true),
PhoneNumber = table.Column<string>(type: "TEXT", nullable: true),
PhoneNumberConfirmed = table.Column<bool>(type: "INTEGER", nullable: false),
TwoFactorEnabled = table.Column<bool>(type: "INTEGER", nullable: false),
LockoutEnd = table.Column<DateTimeOffset>(type: "TEXT", nullable: true),
LockoutEnabled = table.Column<bool>(type: "INTEGER", nullable: false),
AccessFailedCount = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetUsers", x => x.Id);
});
migrationBuilder.CreateTable(
name: "AspNetRoleClaims",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
RoleId = table.Column<string>(type: "TEXT", nullable: false),
ClaimType = table.Column<string>(type: "TEXT", nullable: true),
ClaimValue = table.Column<string>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetRoleClaims", x => x.Id);
table.ForeignKey(
name: "FK_AspNetRoleClaims_AspNetRoles_RoleId",
column: x => x.RoleId,
principalTable: "AspNetRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "AspNetUserClaims",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
UserId = table.Column<string>(type: "TEXT", nullable: false),
ClaimType = table.Column<string>(type: "TEXT", nullable: true),
ClaimValue = table.Column<string>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetUserClaims", x => x.Id);
table.ForeignKey(
name: "FK_AspNetUserClaims_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "AspNetUserLogins",
columns: table => new
{
LoginProvider = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
ProviderKey = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
ProviderDisplayName = table.Column<string>(type: "TEXT", nullable: true),
UserId = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetUserLogins", x => new { x.LoginProvider, x.ProviderKey });
table.ForeignKey(
name: "FK_AspNetUserLogins_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "AspNetUserRoles",
columns: table => new
{
UserId = table.Column<string>(type: "TEXT", nullable: false),
RoleId = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetUserRoles", x => new { x.UserId, x.RoleId });
table.ForeignKey(
name: "FK_AspNetUserRoles_AspNetRoles_RoleId",
column: x => x.RoleId,
principalTable: "AspNetRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_AspNetUserRoles_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "AspNetUserTokens",
columns: table => new
{
UserId = table.Column<string>(type: "TEXT", nullable: false),
LoginProvider = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
Name = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
Value = table.Column<string>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetUserTokens", x => new { x.UserId, x.LoginProvider, x.Name });
table.ForeignKey(
name: "FK_AspNetUserTokens_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_AspNetRoleClaims_RoleId",
table: "AspNetRoleClaims",
column: "RoleId");
migrationBuilder.CreateIndex(
name: "RoleNameIndex",
table: "AspNetRoles",
column: "NormalizedName",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_AspNetUserClaims_UserId",
table: "AspNetUserClaims",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_AspNetUserLogins_UserId",
table: "AspNetUserLogins",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_AspNetUserRoles_RoleId",
table: "AspNetUserRoles",
column: "RoleId");
migrationBuilder.CreateIndex(
name: "EmailIndex",
table: "AspNetUsers",
column: "NormalizedEmail");
migrationBuilder.CreateIndex(
name: "UserNameIndex",
table: "AspNetUsers",
column: "NormalizedUserName",
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "AspNetRoleClaims");
migrationBuilder.DropTable(
name: "AspNetUserClaims");
migrationBuilder.DropTable(
name: "AspNetUserLogins");
migrationBuilder.DropTable(
name: "AspNetUserRoles");
migrationBuilder.DropTable(
name: "AspNetUserTokens");
migrationBuilder.DropTable(
name: "AspNetRoles");
migrationBuilder.DropTable(
name: "AspNetUsers");
}
}
}
@@ -0,0 +1,275 @@
// <auto-generated />
using System;
using MTG_CollectionVerwaltung.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace MTG_CollectionVerwaltung.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20250819133730_AddMustChangePasswordToUsers")]
partial class AddMustChangePasswordToUsers
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "8.0.19");
modelBuilder.Entity("MTG_CollectionVerwaltung.Data.ApplicationUser", b =>
{
b.Property<string>("Id")
.HasColumnType("TEXT");
b.Property<int>("AccessFailedCount")
.HasColumnType("INTEGER");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("TEXT");
b.Property<string>("Email")
.HasMaxLength(256)
.HasColumnType("TEXT");
b.Property<bool>("EmailConfirmed")
.HasColumnType("INTEGER");
b.Property<bool>("LockoutEnabled")
.HasColumnType("INTEGER");
b.Property<DateTimeOffset?>("LockoutEnd")
.HasColumnType("TEXT");
b.Property<bool>("MustChangePassword")
.HasColumnType("INTEGER");
b.Property<string>("NormalizedEmail")
.HasMaxLength(256)
.HasColumnType("TEXT");
b.Property<string>("NormalizedUserName")
.HasMaxLength(256)
.HasColumnType("TEXT");
b.Property<string>("PasswordHash")
.HasColumnType("TEXT");
b.Property<string>("PhoneNumber")
.HasColumnType("TEXT");
b.Property<bool>("PhoneNumberConfirmed")
.HasColumnType("INTEGER");
b.Property<string>("SecurityStamp")
.HasColumnType("TEXT");
b.Property<bool>("TwoFactorEnabled")
.HasColumnType("INTEGER");
b.Property<string>("UserName")
.HasMaxLength(256)
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("NormalizedEmail")
.HasDatabaseName("EmailIndex");
b.HasIndex("NormalizedUserName")
.IsUnique()
.HasDatabaseName("UserNameIndex");
b.ToTable("AspNetUsers", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
{
b.Property<string>("Id")
.HasColumnType("TEXT");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("TEXT");
b.Property<string>("Name")
.HasMaxLength(256)
.HasColumnType("TEXT");
b.Property<string>("NormalizedName")
.HasMaxLength(256)
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("NormalizedName")
.IsUnique()
.HasDatabaseName("RoleNameIndex");
b.ToTable("AspNetRoles", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("ClaimType")
.HasColumnType("TEXT");
b.Property<string>("ClaimValue")
.HasColumnType("TEXT");
b.Property<string>("RoleId")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("AspNetRoleClaims", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("ClaimType")
.HasColumnType("TEXT");
b.Property<string>("ClaimValue")
.HasColumnType("TEXT");
b.Property<string>("UserId")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("AspNetUserClaims", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.Property<string>("LoginProvider")
.HasMaxLength(128)
.HasColumnType("TEXT");
b.Property<string>("ProviderKey")
.HasMaxLength(128)
.HasColumnType("TEXT");
b.Property<string>("ProviderDisplayName")
.HasColumnType("TEXT");
b.Property<string>("UserId")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("LoginProvider", "ProviderKey");
b.HasIndex("UserId");
b.ToTable("AspNetUserLogins", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
{
b.Property<string>("UserId")
.HasColumnType("TEXT");
b.Property<string>("RoleId")
.HasColumnType("TEXT");
b.HasKey("UserId", "RoleId");
b.HasIndex("RoleId");
b.ToTable("AspNetUserRoles", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.Property<string>("UserId")
.HasColumnType("TEXT");
b.Property<string>("LoginProvider")
.HasMaxLength(128)
.HasColumnType("TEXT");
b.Property<string>("Name")
.HasMaxLength(128)
.HasColumnType("TEXT");
b.Property<string>("Value")
.HasColumnType("TEXT");
b.HasKey("UserId", "LoginProvider", "Name");
b.ToTable("AspNetUserTokens", (string)null);
});
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("MTG_CollectionVerwaltung.Data.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.HasOne("MTG_CollectionVerwaltung.Data.ApplicationUser", 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("MTG_CollectionVerwaltung.Data.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.HasOne("MTG_CollectionVerwaltung.Data.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,29 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace MTG_CollectionVerwaltung.Migrations
{
/// <inheritdoc />
public partial class AddMustChangePasswordToUsers : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "MustChangePassword",
table: "AspNetUsers",
type: "INTEGER",
nullable: false,
defaultValue: false);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "MustChangePassword",
table: "AspNetUsers");
}
}
}
@@ -0,0 +1,272 @@
// <auto-generated />
using System;
using MTG_CollectionVerwaltung.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace MTG_CollectionVerwaltung.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
partial class ApplicationDbContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "8.0.19");
modelBuilder.Entity("MTG_CollectionVerwaltung.Data.ApplicationUser", b =>
{
b.Property<string>("Id")
.HasColumnType("TEXT");
b.Property<int>("AccessFailedCount")
.HasColumnType("INTEGER");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("TEXT");
b.Property<string>("Email")
.HasMaxLength(256)
.HasColumnType("TEXT");
b.Property<bool>("EmailConfirmed")
.HasColumnType("INTEGER");
b.Property<bool>("LockoutEnabled")
.HasColumnType("INTEGER");
b.Property<DateTimeOffset?>("LockoutEnd")
.HasColumnType("TEXT");
b.Property<bool>("MustChangePassword")
.HasColumnType("INTEGER");
b.Property<string>("NormalizedEmail")
.HasMaxLength(256)
.HasColumnType("TEXT");
b.Property<string>("NormalizedUserName")
.HasMaxLength(256)
.HasColumnType("TEXT");
b.Property<string>("PasswordHash")
.HasColumnType("TEXT");
b.Property<string>("PhoneNumber")
.HasColumnType("TEXT");
b.Property<bool>("PhoneNumberConfirmed")
.HasColumnType("INTEGER");
b.Property<string>("SecurityStamp")
.HasColumnType("TEXT");
b.Property<bool>("TwoFactorEnabled")
.HasColumnType("INTEGER");
b.Property<string>("UserName")
.HasMaxLength(256)
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("NormalizedEmail")
.HasDatabaseName("EmailIndex");
b.HasIndex("NormalizedUserName")
.IsUnique()
.HasDatabaseName("UserNameIndex");
b.ToTable("AspNetUsers", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
{
b.Property<string>("Id")
.HasColumnType("TEXT");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("TEXT");
b.Property<string>("Name")
.HasMaxLength(256)
.HasColumnType("TEXT");
b.Property<string>("NormalizedName")
.HasMaxLength(256)
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("NormalizedName")
.IsUnique()
.HasDatabaseName("RoleNameIndex");
b.ToTable("AspNetRoles", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("ClaimType")
.HasColumnType("TEXT");
b.Property<string>("ClaimValue")
.HasColumnType("TEXT");
b.Property<string>("RoleId")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("AspNetRoleClaims", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("ClaimType")
.HasColumnType("TEXT");
b.Property<string>("ClaimValue")
.HasColumnType("TEXT");
b.Property<string>("UserId")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("AspNetUserClaims", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.Property<string>("LoginProvider")
.HasMaxLength(128)
.HasColumnType("TEXT");
b.Property<string>("ProviderKey")
.HasMaxLength(128)
.HasColumnType("TEXT");
b.Property<string>("ProviderDisplayName")
.HasColumnType("TEXT");
b.Property<string>("UserId")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("LoginProvider", "ProviderKey");
b.HasIndex("UserId");
b.ToTable("AspNetUserLogins", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
{
b.Property<string>("UserId")
.HasColumnType("TEXT");
b.Property<string>("RoleId")
.HasColumnType("TEXT");
b.HasKey("UserId", "RoleId");
b.HasIndex("RoleId");
b.ToTable("AspNetUserRoles", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.Property<string>("UserId")
.HasColumnType("TEXT");
b.Property<string>("LoginProvider")
.HasMaxLength(128)
.HasColumnType("TEXT");
b.Property<string>("Name")
.HasMaxLength(128)
.HasColumnType("TEXT");
b.Property<string>("Value")
.HasColumnType("TEXT");
b.HasKey("UserId", "LoginProvider", "Name");
b.ToTable("AspNetUserTokens", (string)null);
});
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("MTG_CollectionVerwaltung.Data.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.HasOne("MTG_CollectionVerwaltung.Data.ApplicationUser", 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("MTG_CollectionVerwaltung.Data.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.HasOne("MTG_CollectionVerwaltung.Data.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,341 @@
// <auto-generated />
using System;
using MTG_CollectionVerwaltung.Data.MTGCollection;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace MTG_CollectionVerwaltung.Data.Migrations.MTG
{
[DbContext(typeof(MTGContext))]
[Migration("20250828091558_MTG_InitialCreate")]
partial class MTG_InitialCreate
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "8.0.19");
modelBuilder.Entity("MTG_CollectionVerwaltung.Data.MTGCollection.Card", b =>
{
b.Property<string>("Id")
.HasColumnType("TEXT");
b.Property<string>("CardName")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<int>("Cmc")
.HasColumnType("INTEGER");
b.Property<string>("CollectorNumber")
.HasColumnType("TEXT");
b.Property<bool>("Foil")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER")
.HasDefaultValue(false);
b.Property<string>("ManaCost")
.HasColumnType("TEXT");
b.Property<bool>("NonFoil")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER")
.HasDefaultValue(false);
b.Property<string>("OtherFace")
.HasColumnType("TEXT");
b.Property<string>("Power")
.HasColumnType("TEXT");
b.Property<string>("Rarity")
.HasColumnType("TEXT");
b.Property<string>("SetCode")
.IsRequired()
.HasMaxLength(10)
.HasColumnType("TEXT");
b.Property<int>("SuperTypeId")
.HasColumnType("INTEGER");
b.Property<string>("Toughness")
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("CardName");
b.HasIndex("SetCode");
b.HasIndex("SuperTypeId");
b.HasIndex("CollectorNumber", "SetCode");
b.ToTable("Cards");
});
modelBuilder.Entity("MTG_CollectionVerwaltung.Data.MTGCollection.CardCollection", b =>
{
b.Property<string>("CardId")
.HasColumnType("TEXT");
b.Property<string>("UserId")
.HasColumnType("TEXT");
b.Property<int>("Count")
.HasColumnType("INTEGER");
b.HasKey("CardId", "UserId");
b.HasIndex("UserId");
b.ToTable("CardCollections");
});
modelBuilder.Entity("MTG_CollectionVerwaltung.Data.MTGCollection.CardPrinting", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("CardId")
.IsRequired()
.HasMaxLength(40)
.HasColumnType("TEXT");
b.Property<string>("FlavorText")
.HasColumnType("TEXT");
b.Property<string>("ImageUriLarge")
.HasColumnType("TEXT");
b.Property<string>("ImageUriNormal")
.HasColumnType("TEXT");
b.Property<string>("ImageUriSmall")
.HasColumnType("TEXT");
b.Property<string>("Lang")
.IsRequired()
.HasMaxLength(5)
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("TEXT")
.UseCollation("NOCASE");
b.Property<string>("OracleText")
.HasColumnType("TEXT")
.UseCollation("NOCASE");
b.HasKey("Id");
b.HasIndex("Name");
b.HasIndex("OracleText");
b.HasIndex("CardId", "Lang")
.IsUnique();
b.ToTable("CardPrintings");
});
modelBuilder.Entity("MTG_CollectionVerwaltung.Data.MTGCollection.CardPrintingFts", b =>
{
b.Property<string>("CardId")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("FlavorText")
.HasColumnType("TEXT");
b.Property<string>("Lang")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("OracleText")
.HasColumnType("TEXT");
b.ToTable((string)null);
b.ToView(null, (string)null);
});
modelBuilder.Entity("MTG_CollectionVerwaltung.Data.MTGCollection.CardType", b =>
{
b.Property<string>("CardId")
.HasColumnType("TEXT");
b.Property<int>("TypeId")
.HasColumnType("INTEGER");
b.HasKey("CardId", "TypeId");
b.HasIndex("TypeId");
b.ToTable("CardTypes");
});
modelBuilder.Entity("MTG_CollectionVerwaltung.Data.MTGCollection.MTGType", b =>
{
b.Property<int>("TypeId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("TypeDe")
.IsRequired()
.HasColumnType("TEXT")
.UseCollation("NOCASE");
b.Property<string>("TypeEn")
.IsRequired()
.HasColumnType("TEXT")
.UseCollation("NOCASE");
b.HasKey("TypeId");
b.ToTable("Types");
});
modelBuilder.Entity("MTG_CollectionVerwaltung.Data.MTGCollection.Set", b =>
{
b.Property<string>("SetCode")
.HasMaxLength(10)
.HasColumnType("TEXT");
b.Property<int>("CardCount")
.HasColumnType("INTEGER");
b.Property<DateTime>("ReleaseDate")
.HasColumnType("TEXT");
b.Property<string>("SetIcon")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("SetName")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("TEXT");
b.Property<string>("SetType")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("SetCode");
b.ToTable("Sets");
});
modelBuilder.Entity("MTG_CollectionVerwaltung.Data.MTGCollection.Supertype", b =>
{
b.Property<int>("TypeId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("TypeDe")
.IsRequired()
.HasColumnType("TEXT")
.UseCollation("NOCASE");
b.Property<string>("TypeEn")
.IsRequired()
.HasColumnType("TEXT")
.UseCollation("NOCASE");
b.HasKey("TypeId");
b.ToTable("Supertypes");
});
modelBuilder.Entity("MTG_CollectionVerwaltung.Data.MTGCollection.Card", b =>
{
b.HasOne("MTG_CollectionVerwaltung.Data.MTGCollection.Set", "Set")
.WithMany("Cards")
.HasForeignKey("SetCode")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("MTG_CollectionVerwaltung.Data.MTGCollection.Supertype", "SuperType")
.WithMany()
.HasForeignKey("SuperTypeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Set");
b.Navigation("SuperType");
});
modelBuilder.Entity("MTG_CollectionVerwaltung.Data.MTGCollection.CardCollection", b =>
{
b.HasOne("MTG_CollectionVerwaltung.Data.MTGCollection.Card", "Card")
.WithMany("Collections")
.HasForeignKey("CardId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Card");
});
modelBuilder.Entity("MTG_CollectionVerwaltung.Data.MTGCollection.CardPrinting", b =>
{
b.HasOne("MTG_CollectionVerwaltung.Data.MTGCollection.Card", "Card")
.WithMany("Printings")
.HasForeignKey("CardId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Card");
});
modelBuilder.Entity("MTG_CollectionVerwaltung.Data.MTGCollection.CardType", b =>
{
b.HasOne("MTG_CollectionVerwaltung.Data.MTGCollection.Card", "Card")
.WithMany("CardTypes")
.HasForeignKey("CardId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("MTG_CollectionVerwaltung.Data.MTGCollection.MTGType", "Type")
.WithMany()
.HasForeignKey("TypeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Card");
b.Navigation("Type");
});
modelBuilder.Entity("MTG_CollectionVerwaltung.Data.MTGCollection.Card", b =>
{
b.Navigation("CardTypes");
b.Navigation("Collections");
b.Navigation("Printings");
});
modelBuilder.Entity("MTG_CollectionVerwaltung.Data.MTGCollection.Set", b =>
{
b.Navigation("Cards");
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,237 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace MTG_CollectionVerwaltung.Data.Migrations.MTG
{
/// <inheritdoc />
public partial class MTG_InitialCreate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Sets",
columns: table => new
{
SetCode = table.Column<string>(type: "TEXT", maxLength: 10, nullable: false),
SetName = table.Column<string>(type: "TEXT", maxLength: 50, nullable: false),
SetIcon = table.Column<string>(type: "TEXT", nullable: false),
SetType = table.Column<string>(type: "TEXT", nullable: false),
CardCount = table.Column<int>(type: "INTEGER", nullable: false),
ReleaseDate = table.Column<DateTime>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Sets", x => x.SetCode);
});
migrationBuilder.CreateTable(
name: "Supertypes",
columns: table => new
{
TypeId = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
TypeEn = table.Column<string>(type: "TEXT", nullable: false, collation: "NOCASE"),
TypeDe = table.Column<string>(type: "TEXT", nullable: false, collation: "NOCASE")
},
constraints: table =>
{
table.PrimaryKey("PK_Supertypes", x => x.TypeId);
});
migrationBuilder.CreateTable(
name: "Types",
columns: table => new
{
TypeId = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
TypeEn = table.Column<string>(type: "TEXT", nullable: false, collation: "NOCASE"),
TypeDe = table.Column<string>(type: "TEXT", nullable: false, collation: "NOCASE")
},
constraints: table =>
{
table.PrimaryKey("PK_Types", x => x.TypeId);
});
migrationBuilder.CreateTable(
name: "Cards",
columns: table => new
{
Id = table.Column<string>(type: "TEXT", nullable: false),
SetCode = table.Column<string>(type: "TEXT", maxLength: 10, nullable: false),
CardName = table.Column<string>(type: "TEXT", maxLength: 100, nullable: false),
CollectorNumber = table.Column<string>(type: "TEXT", nullable: true),
ManaCost = table.Column<string>(type: "TEXT", nullable: true),
Foil = table.Column<bool>(type: "INTEGER", nullable: false, defaultValue: false),
NonFoil = table.Column<bool>(type: "INTEGER", nullable: false, defaultValue: false),
Rarity = table.Column<string>(type: "TEXT", nullable: true),
Power = table.Column<string>(type: "TEXT", nullable: true),
Toughness = table.Column<string>(type: "TEXT", nullable: true),
SuperTypeId = table.Column<int>(type: "INTEGER", nullable: false),
Cmc = table.Column<int>(type: "INTEGER", nullable: false),
OtherFace = table.Column<string>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Cards", x => x.Id);
table.ForeignKey(
name: "FK_Cards_Sets_SetCode",
column: x => x.SetCode,
principalTable: "Sets",
principalColumn: "SetCode",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Cards_Supertypes_SuperTypeId",
column: x => x.SuperTypeId,
principalTable: "Supertypes",
principalColumn: "TypeId",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "CardCollections",
columns: table => new
{
CardId = table.Column<string>(type: "TEXT", nullable: false),
UserId = table.Column<string>(type: "TEXT", nullable: false),
Count = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_CardCollections", x => new { x.CardId, x.UserId });
table.ForeignKey(
name: "FK_CardCollections_Cards_CardId",
column: x => x.CardId,
principalTable: "Cards",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "CardPrintings",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
CardId = table.Column<string>(type: "TEXT", maxLength: 40, nullable: false),
Lang = table.Column<string>(type: "TEXT", maxLength: 5, nullable: false),
Name = table.Column<string>(type: "TEXT", maxLength: 100, nullable: false, collation: "NOCASE"),
OracleText = table.Column<string>(type: "TEXT", nullable: true, collation: "NOCASE"),
FlavorText = table.Column<string>(type: "TEXT", nullable: true),
ImageUriSmall = table.Column<string>(type: "TEXT", nullable: true),
ImageUriNormal = table.Column<string>(type: "TEXT", nullable: true),
ImageUriLarge = table.Column<string>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_CardPrintings", x => x.Id);
table.ForeignKey(
name: "FK_CardPrintings_Cards_CardId",
column: x => x.CardId,
principalTable: "Cards",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "CardTypes",
columns: table => new
{
CardId = table.Column<string>(type: "TEXT", nullable: false),
TypeId = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_CardTypes", x => new { x.CardId, x.TypeId });
table.ForeignKey(
name: "FK_CardTypes_Cards_CardId",
column: x => x.CardId,
principalTable: "Cards",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_CardTypes_Types_TypeId",
column: x => x.TypeId,
principalTable: "Types",
principalColumn: "TypeId",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_CardCollections_UserId",
table: "CardCollections",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_CardPrintings_CardId_Lang",
table: "CardPrintings",
columns: new[] { "CardId", "Lang" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_CardPrintings_Name",
table: "CardPrintings",
column: "Name");
migrationBuilder.CreateIndex(
name: "IX_CardPrintings_OracleText",
table: "CardPrintings",
column: "OracleText");
migrationBuilder.CreateIndex(
name: "IX_Cards_CardName",
table: "Cards",
column: "CardName");
migrationBuilder.CreateIndex(
name: "IX_Cards_CollectorNumber_SetCode",
table: "Cards",
columns: new[] { "CollectorNumber", "SetCode" });
migrationBuilder.CreateIndex(
name: "IX_Cards_SetCode",
table: "Cards",
column: "SetCode");
migrationBuilder.CreateIndex(
name: "IX_Cards_SuperTypeId",
table: "Cards",
column: "SuperTypeId");
migrationBuilder.CreateIndex(
name: "IX_CardTypes_TypeId",
table: "CardTypes",
column: "TypeId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.Sql("DROP TABLE IF EXISTS CardPrintingsFTS;");
migrationBuilder.DropTable(
name: "CardCollections");
migrationBuilder.DropTable(
name: "CardPrintings");
migrationBuilder.DropTable(
name: "CardTypes");
migrationBuilder.DropTable(
name: "Cards");
migrationBuilder.DropTable(
name: "Types");
migrationBuilder.DropTable(
name: "Sets");
migrationBuilder.DropTable(
name: "Supertypes");
}
}
}
@@ -0,0 +1,338 @@
// <auto-generated />
using System;
using MTG_CollectionVerwaltung.Data.MTGCollection;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace MTG_CollectionVerwaltung.Data.Migrations.MTG
{
[DbContext(typeof(MTGContext))]
partial class MTGContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "8.0.19");
modelBuilder.Entity("MTG_CollectionVerwaltung.Data.MTGCollection.Card", b =>
{
b.Property<string>("Id")
.HasColumnType("TEXT");
b.Property<string>("CardName")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<int>("Cmc")
.HasColumnType("INTEGER");
b.Property<string>("CollectorNumber")
.HasColumnType("TEXT");
b.Property<bool>("Foil")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER")
.HasDefaultValue(false);
b.Property<string>("ManaCost")
.HasColumnType("TEXT");
b.Property<bool>("NonFoil")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER")
.HasDefaultValue(false);
b.Property<string>("OtherFace")
.HasColumnType("TEXT");
b.Property<string>("Power")
.HasColumnType("TEXT");
b.Property<string>("Rarity")
.HasColumnType("TEXT");
b.Property<string>("SetCode")
.IsRequired()
.HasMaxLength(10)
.HasColumnType("TEXT");
b.Property<int>("SuperTypeId")
.HasColumnType("INTEGER");
b.Property<string>("Toughness")
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("CardName");
b.HasIndex("SetCode");
b.HasIndex("SuperTypeId");
b.HasIndex("CollectorNumber", "SetCode");
b.ToTable("Cards");
});
modelBuilder.Entity("MTG_CollectionVerwaltung.Data.MTGCollection.CardCollection", b =>
{
b.Property<string>("CardId")
.HasColumnType("TEXT");
b.Property<string>("UserId")
.HasColumnType("TEXT");
b.Property<int>("Count")
.HasColumnType("INTEGER");
b.HasKey("CardId", "UserId");
b.HasIndex("UserId");
b.ToTable("CardCollections");
});
modelBuilder.Entity("MTG_CollectionVerwaltung.Data.MTGCollection.CardPrinting", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("CardId")
.IsRequired()
.HasMaxLength(40)
.HasColumnType("TEXT");
b.Property<string>("FlavorText")
.HasColumnType("TEXT");
b.Property<string>("ImageUriLarge")
.HasColumnType("TEXT");
b.Property<string>("ImageUriNormal")
.HasColumnType("TEXT");
b.Property<string>("ImageUriSmall")
.HasColumnType("TEXT");
b.Property<string>("Lang")
.IsRequired()
.HasMaxLength(5)
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("TEXT")
.UseCollation("NOCASE");
b.Property<string>("OracleText")
.HasColumnType("TEXT")
.UseCollation("NOCASE");
b.HasKey("Id");
b.HasIndex("Name");
b.HasIndex("OracleText");
b.HasIndex("CardId", "Lang")
.IsUnique();
b.ToTable("CardPrintings");
});
modelBuilder.Entity("MTG_CollectionVerwaltung.Data.MTGCollection.CardPrintingFts", b =>
{
b.Property<string>("CardId")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("FlavorText")
.HasColumnType("TEXT");
b.Property<string>("Lang")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("OracleText")
.HasColumnType("TEXT");
b.ToTable((string)null);
b.ToView(null, (string)null);
});
modelBuilder.Entity("MTG_CollectionVerwaltung.Data.MTGCollection.CardType", b =>
{
b.Property<string>("CardId")
.HasColumnType("TEXT");
b.Property<int>("TypeId")
.HasColumnType("INTEGER");
b.HasKey("CardId", "TypeId");
b.HasIndex("TypeId");
b.ToTable("CardTypes");
});
modelBuilder.Entity("MTG_CollectionVerwaltung.Data.MTGCollection.MTGType", b =>
{
b.Property<int>("TypeId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("TypeDe")
.IsRequired()
.HasColumnType("TEXT")
.UseCollation("NOCASE");
b.Property<string>("TypeEn")
.IsRequired()
.HasColumnType("TEXT")
.UseCollation("NOCASE");
b.HasKey("TypeId");
b.ToTable("Types");
});
modelBuilder.Entity("MTG_CollectionVerwaltung.Data.MTGCollection.Set", b =>
{
b.Property<string>("SetCode")
.HasMaxLength(10)
.HasColumnType("TEXT");
b.Property<int>("CardCount")
.HasColumnType("INTEGER");
b.Property<DateTime>("ReleaseDate")
.HasColumnType("TEXT");
b.Property<string>("SetIcon")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("SetName")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("TEXT");
b.Property<string>("SetType")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("SetCode");
b.ToTable("Sets");
});
modelBuilder.Entity("MTG_CollectionVerwaltung.Data.MTGCollection.Supertype", b =>
{
b.Property<int>("TypeId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("TypeDe")
.IsRequired()
.HasColumnType("TEXT")
.UseCollation("NOCASE");
b.Property<string>("TypeEn")
.IsRequired()
.HasColumnType("TEXT")
.UseCollation("NOCASE");
b.HasKey("TypeId");
b.ToTable("Supertypes");
});
modelBuilder.Entity("MTG_CollectionVerwaltung.Data.MTGCollection.Card", b =>
{
b.HasOne("MTG_CollectionVerwaltung.Data.MTGCollection.Set", "Set")
.WithMany("Cards")
.HasForeignKey("SetCode")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("MTG_CollectionVerwaltung.Data.MTGCollection.Supertype", "SuperType")
.WithMany()
.HasForeignKey("SuperTypeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Set");
b.Navigation("SuperType");
});
modelBuilder.Entity("MTG_CollectionVerwaltung.Data.MTGCollection.CardCollection", b =>
{
b.HasOne("MTG_CollectionVerwaltung.Data.MTGCollection.Card", "Card")
.WithMany("Collections")
.HasForeignKey("CardId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Card");
});
modelBuilder.Entity("MTG_CollectionVerwaltung.Data.MTGCollection.CardPrinting", b =>
{
b.HasOne("MTG_CollectionVerwaltung.Data.MTGCollection.Card", "Card")
.WithMany("Printings")
.HasForeignKey("CardId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Card");
});
modelBuilder.Entity("MTG_CollectionVerwaltung.Data.MTGCollection.CardType", b =>
{
b.HasOne("MTG_CollectionVerwaltung.Data.MTGCollection.Card", "Card")
.WithMany("CardTypes")
.HasForeignKey("CardId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("MTG_CollectionVerwaltung.Data.MTGCollection.MTGType", "Type")
.WithMany()
.HasForeignKey("TypeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Card");
b.Navigation("Type");
});
modelBuilder.Entity("MTG_CollectionVerwaltung.Data.MTGCollection.Card", b =>
{
b.Navigation("CardTypes");
b.Navigation("Collections");
b.Navigation("Printings");
});
modelBuilder.Entity("MTG_CollectionVerwaltung.Data.MTGCollection.Set", b =>
{
b.Navigation("Cards");
});
#pragma warning restore 612, 618
}
}
}