using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; using OnProfNext.Shared.Models; //Konfiguriert die User-Entität für Entity Framework Core namespace OnProfNext.Server.Configurations { public class UserConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder entity) { entity.ToTable("Users"); // Primary Key entity.HasKey(u => u.Id); // Username entity.Property(u => u.Username) .IsRequired() .HasMaxLength(50); // Email entity.Property(u => u.Email) .IsRequired() .HasMaxLength(100); // Password Hash (wird nicht angezeigt, aber wichtig) entity.Property(u => u.PasswordHash) .IsRequired() .HasMaxLength(512); // First / Last Name entity.Property(u => u.FirstName) .HasMaxLength(100); entity.Property(u => u.LastName) .HasMaxLength(100); // Mandant entity.Property(u => u.MandantId) .HasDefaultValue(1); // Aktivitätsstatus entity.Property(u => u.IsActive) .HasDefaultValue(true); // Timestamps entity.Property(u => u.CreatedAt) .HasDefaultValueSql("SYSDATETIME()") .ValueGeneratedOnAdd(); entity.Property(u => u.UpdatedAt) .HasDefaultValueSql("SYSDATETIME()") .ValueGeneratedOnAddOrUpdate(); } } }