using BlueLaminate.EFCore.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace BlueLaminate.EFCore.Configurations; public class TradeConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder entity) { // Steam's trade id is the natural key for an observed trade. Nullable (some // trades are reconstructed without one); Postgres keeps multiple NULLs distinct. entity.HasIndex(e => e.SteamTradeId).IsUnique(); entity.HasOne(e => e.FromUser) .WithMany(u => u.TradesSent) .HasForeignKey(e => e.FromUserId) .OnDelete(DeleteBehavior.Restrict); entity.HasOne(e => e.ToUser) .WithMany(u => u.TradesReceived) .HasForeignKey(e => e.ToUserId) .OnDelete(DeleteBehavior.Restrict); } }