using Heimdall.Domain.Entities; using Heimdall.Infrastructure.Identity; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace Heimdall.Infrastructure.Data.Configurations; public class UserSiteConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { builder.ToTable("user_sites"); builder.HasKey(us => new { us.UserId, us.SiteId }); builder.HasOne() .WithMany() .HasForeignKey(us => us.UserId) .OnDelete(DeleteBehavior.Cascade); builder.HasOne(us => us.Site) .WithMany() .HasForeignKey(us => us.SiteId) .OnDelete(DeleteBehavior.Restrict); // Index for "find all users for a site" queries builder.HasIndex(us => us.SiteId); } }