NotificationConfiguration.cs 1.1 KB

123456789101112131415161718192021222324
  1. using Microsoft.EntityFrameworkCore;
  2. using Microsoft.EntityFrameworkCore.Metadata.Builders;
  3. namespace Infrastructure.Persistence.Configurations.Notifications;
  4. public class NotificationConfiguration : IEntityTypeConfiguration<Domain.Entities.Notifications.Notification>
  5. {
  6. public void Configure(EntityTypeBuilder<Domain.Entities.Notifications.Notification> builder)
  7. {
  8. builder.ToTable(nameof(Notification), x => x.HasComment("알림"));
  9. builder.HasKey(x => x.ID);
  10. builder.HasOne(x => x.Member).WithMany().HasForeignKey(x => x.MemberID).OnDelete(DeleteBehavior.Cascade);
  11. builder.HasIndex(x => new { x.MemberID, x.IsRead, x.CreatedAt }).IsDescending(false, false, true);
  12. builder.HasIndex(x => new { x.MemberID, x.Type, x.CreatedAt }).IsDescending(false, false, true);
  13. builder.Property(x => x.Title).HasMaxLength(200).IsRequired();
  14. builder.Property(x => x.Message).HasMaxLength(500).IsRequired();
  15. builder.Property(x => x.ActionUrl).HasMaxLength(500);
  16. builder.Property(x => x.RelatedType).HasMaxLength(50);
  17. builder.Property(x => x.ImageUrl).HasMaxLength(500);
  18. }
  19. }