DonationAlertAttemptConfiguration.cs 980 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 DonationAlertAttemptConfiguration : IEntityTypeConfiguration<DonationAlertAttempt>
  6. {
  7. public void Configure(EntityTypeBuilder<DonationAlertAttempt> builder)
  8. {
  9. builder.ToTable(nameof(DonationAlertAttempt), x => x.HasComment("후원 알림 재시도 기록"));
  10. builder.HasKey(x => x.ID);
  11. builder.HasOne(x => x.Donation).WithMany().HasForeignKey(x => x.DonationID).OnDelete(DeleteBehavior.NoAction);
  12. builder.HasOne(x => x.DonationAlert).WithMany(x => x.Attempts).HasForeignKey(x => x.DonationAlertID).OnDelete(DeleteBehavior.Cascade);
  13. builder.HasIndex(x => new { x.DonationID, x.DonationAlertID });
  14. builder.Property(x => x.IpAddress).HasMaxLength(64);
  15. builder.Property(x => x.UserAgent).HasMaxLength(1024);
  16. }
  17. }