GameCategoryMapConfiguration.cs 852 B

12345678910111213141516171819
  1. using Domain.Entities.Store;
  2. using Microsoft.EntityFrameworkCore;
  3. using Microsoft.EntityFrameworkCore.Metadata.Builders;
  4. namespace Infrastructure.Persistence.Configurations.Store;
  5. public sealed class GameCategoryMapConfiguration : IEntityTypeConfiguration<GameCategoryMap>
  6. {
  7. public void Configure(EntityTypeBuilder<GameCategoryMap> builder)
  8. {
  9. builder.ToTable(nameof(GameCategoryMap), t => t.HasComment("게임-카테고리 N:M"));
  10. builder.HasKey(x => new { x.GameID, x.GameCategoryID });
  11. builder.HasOne(x => x.Game).WithMany(x => x.GameCategoryMap).HasForeignKey(x => x.GameID).OnDelete(DeleteBehavior.Cascade);
  12. builder.HasOne(x => x.GameCategory).WithMany(x => x.GameCategoryMap).HasForeignKey(x => x.GameCategoryID).OnDelete(DeleteBehavior.Cascade);
  13. builder.HasIndex(x => x.GameCategoryID);
  14. }
  15. }