using BlueLaminate.EFCore.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace BlueLaminate.EFCore.Configurations; public class SkinConditionSweepConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder entity) { // One checkpoint per band per site: the natural key, and what the upsert // ("stamp") in SweepCheckpoints relies on. entity.HasIndex(e => new { e.SkinConditionId, e.Source }).IsUnique(); // Each site's sweep orders its bands never-swept-first then stalest; index the // ordering it scans (filter by source, sort by swept_at). entity.HasIndex(e => new { e.Source, e.SweptAt }); entity.HasOne(e => e.SkinCondition) .WithMany(c => c.Sweeps) .HasForeignKey(e => e.SkinConditionId) .OnDelete(DeleteBehavior.Cascade); } }