CrewSessionConfiguration.cs 800 B

123456789101112131415161718192021
  1. using Domain.Entities.Donations;
  2. using Microsoft.EntityFrameworkCore;
  3. using Microsoft.EntityFrameworkCore.Metadata.Builders;
  4. namespace Infrastructure.Persistence.Configurations.Donations;
  5. public class CrewSessionConfiguration : IEntityTypeConfiguration<CrewSession>
  6. {
  7. public void Configure(EntityTypeBuilder<CrewSession> builder)
  8. {
  9. builder.ToTable(nameof(CrewSession), x => x.HasComment("크루 후원 방송 세션"));
  10. builder.HasKey(x => x.ID);
  11. builder.HasOne(x => x.Crew).WithMany(x => x.Sessions).HasForeignKey(x => x.CrewID).OnDelete(DeleteBehavior.Cascade);
  12. builder.HasIndex(x => new { x.CrewID, x.Status });
  13. builder.HasIndex(x => new { x.CrewID, x.StartedAt });
  14. builder.Property(x => x.Title).HasMaxLength(200).IsRequired();
  15. }
  16. }