DonationRankConfigConfiguration.cs 857 B

123456789101112131415161718192021
  1. using Domain.Entities.Donations;
  2. using Microsoft.EntityFrameworkCore;
  3. using Microsoft.EntityFrameworkCore.Metadata.Builders;
  4. namespace Infrastructure.Persistence.Configurations.Donations;
  5. public class DonationRankConfigConfiguration : IEntityTypeConfiguration<DonationRankConfig>
  6. {
  7. public void Configure(EntityTypeBuilder<DonationRankConfig> builder)
  8. {
  9. builder.ToTable(nameof(DonationRankConfig), 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 => x.ChannelID);
  14. builder.Property(x => x.Title).HasMaxLength(300).IsRequired();
  15. }
  16. }