PaymentOrderConfiguration.cs 1.3 KB

12345678910111213141516171819202122232425262728
  1. using Domain.Entities.Payments;
  2. using Microsoft.EntityFrameworkCore;
  3. using Microsoft.EntityFrameworkCore.Metadata.Builders;
  4. namespace Infrastructure.Persistence.Configurations.Payments;
  5. public class PaymentOrderConfiguration : IEntityTypeConfiguration<PaymentOrder>
  6. {
  7. public void Configure(EntityTypeBuilder<PaymentOrder> builder)
  8. {
  9. builder.HasOne(x => x.Member).WithMany().HasForeignKey(x => x.MemberID).OnDelete(DeleteBehavior.NoAction);
  10. builder.HasIndex(x => x.OrderID).IsUnique();
  11. builder.HasIndex(x => x.TransactionID);
  12. builder.HasIndex(x => x.MemberID);
  13. builder.HasIndex(x => x.Status);
  14. builder.ToTable(nameof(PaymentOrder), x => x.HasComment("PG 결제 주문"));
  15. builder.HasKey(x => x.ID);
  16. builder.Property(x => x.OrderID).HasMaxLength(64).IsRequired();
  17. builder.Property(x => x.MerchantID).HasMaxLength(20).IsRequired();
  18. builder.Property(x => x.OrderName).HasMaxLength(100).IsRequired();
  19. builder.Property(x => x.TransactionID).HasMaxLength(64);
  20. builder.Property(x => x.FailReason).HasMaxLength(500);
  21. builder.Property(x => x.VirtualAccountNumber).HasMaxLength(64);
  22. builder.Property(x => x.VirtualAccountBank).HasMaxLength(32);
  23. builder.Property(x => x.VirtualAccountHolder).HasMaxLength(32);
  24. }
  25. }