From 9128b199e9634a56974825fbc1065f52cde91904 Mon Sep 17 00:00:00 2001 From: Jonas Date: Sun, 7 Dec 2025 19:48:47 +0100 Subject: [PATCH] Switch AltersGruppe ID to ULID and add config Changed AltersGruppe model ID from int to string and now generates ULID automatically. Added AltersGruppeConfiguration for EF Core mapping. Updated ApplicationDbContext to apply configurations from assembly. Removed obsolete migration files and database artifacts. Added Ulid package dependency. --- .vs/JudoWeb/DesignTimeBuild/.dtbcache.v2 | Bin 174419 -> 174798 bytes API/API.csproj | 1 + API/API.csproj.Backup (1).tmp | 32 ----------- API/API.csproj.Backup.tmp | 25 --------- API/Database/ApplicationDbContext.cs | 7 +++ .../AltersGruppeConfiguration.cs | 34 ++++++++++++ .../20251206113128_InitialCreate.Designer.cs | 47 ---------------- .../20251206113128_InitialCreate.cs | 36 ------------- ...206220303_ChangeAgeFieldsToInt.Designer.cs | 45 ---------------- .../20251206220303_ChangeAgeFieldsToInt.cs | 50 ------------------ .../ApplicationDbContextModelSnapshot.cs | 42 --------------- .../Internal/Altersgruppen/AltersGruppe.cs | 8 ++- API/app.db-shm | Bin 32768 -> 0 bytes API/app.db-wal | Bin 78312 -> 0 bytes 14 files changed, 49 insertions(+), 278 deletions(-) delete mode 100644 API/API.csproj.Backup (1).tmp delete mode 100644 API/API.csproj.Backup.tmp create mode 100644 API/Database/Configurations/AltersGruppeConfiguration.cs delete mode 100644 API/Migrations/20251206113128_InitialCreate.Designer.cs delete mode 100644 API/Migrations/20251206113128_InitialCreate.cs delete mode 100644 API/Migrations/20251206220303_ChangeAgeFieldsToInt.Designer.cs delete mode 100644 API/Migrations/20251206220303_ChangeAgeFieldsToInt.cs delete mode 100644 API/Migrations/ApplicationDbContextModelSnapshot.cs delete mode 100644 API/app.db-shm delete mode 100644 API/app.db-wal diff --git a/.vs/JudoWeb/DesignTimeBuild/.dtbcache.v2 b/.vs/JudoWeb/DesignTimeBuild/.dtbcache.v2 index 803c5eae0ea171317047e8b7062133a932745f51..7c118f748eae18322f850b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@ -1,32 +0,0 @@ - - - - net8.0 - enable - enable - - - - - - - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - - - - diff --git a/API/API.csproj.Backup.tmp b/API/API.csproj.Backup.tmp deleted file mode 100644 index 9d39161..0000000 --- a/API/API.csproj.Backup.tmp +++ /dev/null @@ -1,25 +0,0 @@ - - - - net8.0 - enable - enable - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - - - - diff --git a/API/Database/ApplicationDbContext.cs b/API/Database/ApplicationDbContext.cs index 1a9f69b..8d3d152 100644 --- a/API/Database/ApplicationDbContext.cs +++ b/API/Database/ApplicationDbContext.cs @@ -10,5 +10,12 @@ namespace API.Database } public DbSet Altersgruppen { get; set; } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + base.OnModelCreating(modelBuilder); + + modelBuilder.ApplyConfigurationsFromAssembly(typeof(ApplicationDbContext).Assembly); + } } } diff --git a/API/Database/Configurations/AltersGruppeConfiguration.cs b/API/Database/Configurations/AltersGruppeConfiguration.cs new file mode 100644 index 0000000..ba6036f --- /dev/null +++ b/API/Database/Configurations/AltersGruppeConfiguration.cs @@ -0,0 +1,34 @@ +using API.Models.Internal.Altersgruppen; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +namespace API.Database.Configurations +{ + public class AltersGruppeConfiguration : IEntityTypeConfiguration + { + public void Configure(EntityTypeBuilder entity) + { + // Primary Key + entity.HasKey(e => e.Id); + + // Id-Konfiguration + entity.Property(e => e.Id) + .HasMaxLength(26) + .IsRequired() + .ValueGeneratedNever(); + + // Name + entity.Property(e => e.Name) + .HasMaxLength(100) + .IsRequired(); + + // StartingAge + entity.Property(e => e.StartingAge) + .IsRequired(); + + // EndingAge + entity.Property(e => e.EndingAge) + .IsRequired(); + } + } +} diff --git a/API/Migrations/20251206113128_InitialCreate.Designer.cs b/API/Migrations/20251206113128_InitialCreate.Designer.cs deleted file mode 100644 index 8220cb4..0000000 --- a/API/Migrations/20251206113128_InitialCreate.Designer.cs +++ /dev/null @@ -1,47 +0,0 @@ -// -using API.Database; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace API.Migrations -{ - [DbContext(typeof(ApplicationDbContext))] - [Migration("20251206113128_InitialCreate")] - partial class InitialCreate - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "9.0.11"); - - modelBuilder.Entity("API.Models.Internal.Altersgruppen.Altergruppe", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("EndingAge") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Name") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("StartingAge") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Altersgruppen"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/API/Migrations/20251206113128_InitialCreate.cs b/API/Migrations/20251206113128_InitialCreate.cs deleted file mode 100644 index fa435ab..0000000 --- a/API/Migrations/20251206113128_InitialCreate.cs +++ /dev/null @@ -1,36 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace API.Migrations -{ - /// - public partial class InitialCreate : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "Altersgruppen", - columns: table => new - { - Id = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - Name = table.Column(type: "TEXT", nullable: false), - StartingAge = table.Column(type: "TEXT", nullable: false), - EndingAge = table.Column(type: "TEXT", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Altersgruppen", x => x.Id); - }); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "Altersgruppen"); - } - } -} diff --git a/API/Migrations/20251206220303_ChangeAgeFieldsToInt.Designer.cs b/API/Migrations/20251206220303_ChangeAgeFieldsToInt.Designer.cs deleted file mode 100644 index 1997ead..0000000 --- a/API/Migrations/20251206220303_ChangeAgeFieldsToInt.Designer.cs +++ /dev/null @@ -1,45 +0,0 @@ -// -using API.Database; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace API.Migrations -{ - [DbContext(typeof(ApplicationDbContext))] - [Migration("20251206220303_ChangeAgeFieldsToInt")] - partial class ChangeAgeFieldsToInt - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "9.0.11"); - - modelBuilder.Entity("API.Models.Internal.Altersgruppen.AltersGruppe", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("EndingAge") - .HasColumnType("INTEGER"); - - b.Property("Name") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("StartingAge") - .HasColumnType("INTEGER"); - - b.HasKey("Id"); - - b.ToTable("Altersgruppen"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/API/Migrations/20251206220303_ChangeAgeFieldsToInt.cs b/API/Migrations/20251206220303_ChangeAgeFieldsToInt.cs deleted file mode 100644 index fccb536..0000000 --- a/API/Migrations/20251206220303_ChangeAgeFieldsToInt.cs +++ /dev/null @@ -1,50 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace API.Migrations -{ - /// - public partial class ChangeAgeFieldsToInt : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "StartingAge", - table: "Altersgruppen", - type: "INTEGER", - nullable: false, - oldClrType: typeof(string), - oldType: "TEXT"); - - migrationBuilder.AlterColumn( - name: "EndingAge", - table: "Altersgruppen", - type: "INTEGER", - nullable: false, - oldClrType: typeof(string), - oldType: "TEXT"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "StartingAge", - table: "Altersgruppen", - type: "TEXT", - nullable: false, - oldClrType: typeof(int), - oldType: "INTEGER"); - - migrationBuilder.AlterColumn( - name: "EndingAge", - table: "Altersgruppen", - type: "TEXT", - nullable: false, - oldClrType: typeof(int), - oldType: "INTEGER"); - } - } -} diff --git a/API/Migrations/ApplicationDbContextModelSnapshot.cs b/API/Migrations/ApplicationDbContextModelSnapshot.cs deleted file mode 100644 index 4e1d4ce..0000000 --- a/API/Migrations/ApplicationDbContextModelSnapshot.cs +++ /dev/null @@ -1,42 +0,0 @@ -// -using API.Database; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace API.Migrations -{ - [DbContext(typeof(ApplicationDbContext))] - partial class ApplicationDbContextModelSnapshot : ModelSnapshot - { - protected override void BuildModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "9.0.11"); - - modelBuilder.Entity("API.Models.Internal.Altersgruppen.AltersGruppe", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("EndingAge") - .HasColumnType("INTEGER"); - - b.Property("Name") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("StartingAge") - .HasColumnType("INTEGER"); - - b.HasKey("Id"); - - b.ToTable("Altersgruppen"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/API/Models/Internal/Altersgruppen/AltersGruppe.cs b/API/Models/Internal/Altersgruppen/AltersGruppe.cs index 5914805..582de6c 100644 --- a/API/Models/Internal/Altersgruppen/AltersGruppe.cs +++ b/API/Models/Internal/Altersgruppen/AltersGruppe.cs @@ -4,9 +4,15 @@ namespace API.Models.Internal.Altersgruppen { public class AltersGruppe { - public int Id { get; set; } + public string Id { get; set; } public string Name { get; set; } public int StartingAge { get; set; } public int EndingAge { get; set; } + + // Constructor für automatische ULID-Generierung + public AltersGruppe() + { + Id = Ulid.NewUlid().ToString(); + } } } diff --git a/API/app.db-shm b/API/app.db-shm deleted file mode 100644 index 97f3b4165dd46b645afe132f3d97fc658fc91dff..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 32768 zcmeI)JxT*n5CGtb*~EVnO_NKA*Rb{qp1?~8Vl7s7xr@*%A*jcFa!Un`nc!dwX zfnnb6z8!||05g9%jS{<=gNW%Y>vrbV`}y*&yL?+M?=M~-9&c}+7T2F2&u8;L-p^L+ zD1E`C`QU5&5+GUn|oA1AC`9}~SK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PHVu(5-h&v@)$Z3DguA$Yx#MCVdvVRUor5JE^(w%csjx~=Py z;c&1mMiTIyW-1bmi4mhQ8o~I&1c)zurLQpPctZpUynsaIod$ibTg$HNmP%rz?E8dv z+}+dX?)ltxNq_tOuKvS?6H?_b>m+HFWVhe0PPJV*`Q5SdvFil~y!(!eRW9);Os)TH z%&(tX{qb0_SShR1lK4kM009ILKmY**5I_I{1Q0*~fxHvgAS+Ufshic6hFPiCXr@tL zT~}Z2^VS$ux>;pb=z6`bi)lIH0=qBnSB_k&+-1iF>`(%6fxJ8M954b1AbGg^J0O900IagfB*srAbX05R$*dA(Y5bL$F)*a4$mT9eRO*~Uux7}_#BW+2uTjrBD2So4QYbqPlL#MV$?x7g$CUQ?Ue6Onjg zq1P9CHnqA7ODihmJxP|K!CvucCOl*f4qLHKD`TV@w>w7V*kW<0Az{rRC-F zzqI1rNW4pi{-|b3XWfLvQsfWXX=XOSW;*mtOKQ^>I zI+W;-AI!Q^aZ+UMbC)DNrhU0Njv@0}TVS9$*Iep4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