DonationGoalConfigConfiguration.cs 1.3 KB

12345678910111213141516171819202122232425262728
  1. using Domain.Entities.Donations;
  2. using Microsoft.EntityFrameworkCore;
  3. using Microsoft.EntityFrameworkCore.Metadata.Builders;
  4. namespace Infrastructure.Persistence.Configurations.Donations;
  5. public class DonationGoalConfigConfiguration : IEntityTypeConfiguration<DonationGoalConfig>
  6. {
  7. public void Configure(EntityTypeBuilder<DonationGoalConfig> builder)
  8. {
  9. builder.ToTable(nameof(DonationGoalConfig), 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 => new { x.ChannelID, x.MemberID });
  14. builder.HasIndex(x => new { x.ChannelID, x.IsActive });
  15. builder.Property(x => x.Title).HasMaxLength(50).IsRequired();
  16. builder.Property(x => x.BarColor).HasMaxLength(9);
  17. builder.Property(x => x.BarBackgroundColor).HasMaxLength(9);
  18. builder.Property(x => x.TitleFontColor).HasMaxLength(9);
  19. builder.Property(x => x.AmountFontColor).HasMaxLength(9);
  20. builder.Property(x => x.TitleFontFamily).HasMaxLength(100);
  21. builder.Property(x => x.AmountFontFamily).HasMaxLength(100);
  22. }
  23. }