KoogleApp/Koogle.Infrastrcuture/Data/Configurations/UserProfileConfiguration.cs

38 lines
1.1 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();
// Soft delete Filter (optional wenn du das global im DbContext machst, weglassen)
builder.HasQueryFilter(x => !x.IsDeleted);
builder.HasMany(x => x.Clubs)
.WithOne(x => x.UserProfile)
.HasForeignKey(x => x.UserProfileId)
.OnDelete(DeleteBehavior.Cascade);
}
}