SettlementConfiguration.cs 873 B

12345678910111213141516171819202122
  1. using Domain.Entities.Donations;
  2. using Microsoft.EntityFrameworkCore;
  3. using Microsoft.EntityFrameworkCore.Metadata.Builders;
  4. namespace Infrastructure.Persistence.Configurations.Donations;
  5. public class SettlementConfiguration : IEntityTypeConfiguration<Settlement>
  6. {
  7. public void Configure(EntityTypeBuilder<Settlement> builder)
  8. {
  9. builder.ToTable(nameof(Settlement), x => x.HasComment("정산"));
  10. builder.HasKey(x => x.ID);
  11. builder.HasOne(x => x.Channel).WithMany().HasForeignKey(x => x.ChannelID).OnDelete(DeleteBehavior.NoAction);
  12. builder.HasOne(x => x.Member).WithMany().HasForeignKey(x => x.MemberID).OnDelete(DeleteBehavior.NoAction);
  13. builder.HasIndex(x => new { x.ChannelID, x.PeriodStart, x.PeriodEnd });
  14. builder.HasIndex(x => x.Status);
  15. builder.Property(x => x.AdminMemo).HasMaxLength(500);
  16. }
  17. }