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.
This commit is contained in:
@@ -10,5 +10,12 @@ namespace API.Database
|
||||
}
|
||||
|
||||
public DbSet<AltersGruppe> Altersgruppen { get; set; }
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
base.OnModelCreating(modelBuilder);
|
||||
|
||||
modelBuilder.ApplyConfigurationsFromAssembly(typeof(ApplicationDbContext).Assembly);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
34
API/Database/Configurations/AltersGruppeConfiguration.cs
Normal file
34
API/Database/Configurations/AltersGruppeConfiguration.cs
Normal file
@@ -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<AltersGruppe>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<AltersGruppe> 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user