| 12345678910111213141516171819202122 |
- using Domain.Entities.Donations;
- using Microsoft.EntityFrameworkCore;
- using Microsoft.EntityFrameworkCore.Metadata.Builders;
- namespace Infrastructure.Persistence.Configurations.Donations;
- public class DonationRankingConfiguration : IEntityTypeConfiguration<DonationRanking>
- {
- public void Configure(EntityTypeBuilder<DonationRanking> builder)
- {
- builder.ToTable(nameof(DonationRanking), x => x.HasComment("후원 순위"));
- builder.HasKey(x => x.ID);
- builder.HasOne(x => x.Channel).WithMany().HasForeignKey(x => x.ChannelID).OnDelete(DeleteBehavior.Cascade);
- builder.HasOne(x => x.Sponsor).WithMany().HasForeignKey(x => x.SponsorMemberID).OnDelete(DeleteBehavior.NoAction);
- builder.HasIndex(x => new { x.ChannelID, x.SponsorMemberID, x.PeriodType, x.PeriodStart }).IsUnique();
- builder.HasIndex(x => new { x.ChannelID, x.PeriodType, x.PeriodStart, x.Rank });
- builder.Property(x => x.SponsorName).HasMaxLength(40).IsRequired();
- }
- }
|