DonationMetaConfiguration.cs 785 B

12345678910111213141516171819
  1. using Domain.Entities.Donations;
  2. using Microsoft.EntityFrameworkCore;
  3. using Microsoft.EntityFrameworkCore.Metadata.Builders;
  4. namespace Infrastructure.Persistence.Configurations.Donations;
  5. public class DonationMetaConfiguration : IEntityTypeConfiguration<DonationMeta>
  6. {
  7. public void Configure(EntityTypeBuilder<DonationMeta> builder)
  8. {
  9. builder.ToTable(nameof(DonationMeta), x => x.HasComment("후원 공통 설정"));
  10. builder.HasKey(x => x.ID);
  11. builder.HasOne(x => x.Channel).WithMany().HasForeignKey(x => x.ChannelID).OnDelete(DeleteBehavior.Cascade);
  12. builder.HasOne(x => x.Member).WithMany().HasForeignKey(x => x.MemberID).OnDelete(DeleteBehavior.NoAction);
  13. builder.HasIndex(x => new { x.ChannelID, x.MemberID }).IsUnique();
  14. }
  15. }