using Domain.Entities.Crypto; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace Infrastructure.Persistence.Configurations.Crypto; public sealed class CoinCategoryMapConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { builder.HasIndex(x => new { x.CoinID, x.CategoryID }).IsUnique(); builder.HasIndex(x => x.CategoryID); builder.HasOne(x => x.CoinCategory).WithMany(x => x.CoinCategoryMap).HasForeignKey(x => x.CategoryID).OnDelete(DeleteBehavior.Restrict); builder.ToTable(nameof(CoinCategoryMap), t => t.HasComment("코인-카테고리 연결")); builder.HasKey(x => x.ID); builder.Property(x => x.ID).ValueGeneratedOnAdd().HasComment("PK"); builder.Property(x => x.CoinID).IsRequired().HasComment("코인 ID"); builder.Property(x => x.CategoryID).IsRequired().HasComment("카테고리 ID"); } }