KoogleApp/src/Koogle.Infrastructure/Data/Configurations/UserProfileConfiguration.cs

55 lines
1.6 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Koogle.Domain.Entities;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Koogle.Infrastructure.Data.Configurations;
public class UserProfileConfiguration : IEntityTypeConfiguration<UserProfile>
{
public void Configure(EntityTypeBuilder<UserProfile> builder)
{
builder.ToTable("UserProfiles");
builder.HasKey(x => x.Id);
// Keine FK zur Identity-Tabelle nur Guid + Unique Index
builder.Property(x => x.IdentityUserId)
.IsRequired();
builder.HasIndex(x => x.IdentityUserId)
.IsUnique();
builder.Property(x => x.DisplayName)
.HasMaxLength(200)
.IsRequired();
// Optional: Locale ("de-DE", "en-US" etc.)
// 20 Zeichen reichen (RFC5646 i.d.R. kurz). Nicht-Unicode spart Platz.
builder.Property(x => x.Locale)
.HasMaxLength(20)
.IsUnicode(false);
// Optional: TimeZone
// Wenn du Windows-IDs nutzt ("W. Europe Standard Time") sind ~32-40 üblich,
// IANA ("Europe/Berlin") ist kurz. 64 ist ein guter Puffer.
builder.Property(x => x.TimeZone)
.HasMaxLength(64)
.IsUnicode(false);
builder.HasMany(x => x.Clubs)
.WithOne(x => x.UserProfile)
.HasForeignKey(x => x.UserProfileId)
.OnDelete(DeleteBehavior.Cascade);
builder.HasQueryFilter(x => !x.IsDeleted);
}
}