using BlueLaminate.EFCore.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace BlueLaminate.EFCore.Configurations; public class SkinInstanceConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder entity) { // Full precision so exact-match dupe detection isn't defeated by rounding. // CSFloat returns deterministic ~17-digit floats; numeric(20,18) holds them. entity.Property(e => e.FloatValue).HasColumnType("numeric(20,18)"); // The fingerprint that identifies a physical item. NOT unique: duped items // legitimately share a fingerprint, and detecting that collision is the // point. Indexed for fast fingerprint resolution during the sweep. entity.HasIndex(e => new { e.SkinId, e.FloatValue, e.PaintSeed, e.StatTrak, e.Souvenir, }); // Surfacing fresh dupes is a hot query. entity.HasIndex(e => e.SuspectedDupe); entity.HasOne(e => e.Skin) .WithMany(s => s.Instances) .HasForeignKey(e => e.SkinId); // Condition is optional now (derived from float later); set null on delete // rather than restrict so condition rows can change without blocking. entity.HasOne(e => e.Condition) .WithMany(c => c.Instances) .HasForeignKey(e => e.ConditionId) .OnDelete(DeleteBehavior.SetNull); } }