using Core.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace Data.Configurations { public class EventDefinitionConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { builder.HasKey(e => e.Id); // Indexes builder.HasIndex(e => e.Name).IsUnique(); builder.HasIndex(e => e.EventFormat); // Constraints builder.Property(e => e.Name) .IsRequired() .HasMaxLength(128); builder.Property(e => e.ShortName) .HasMaxLength(50); builder.Property(e => e.Description) .HasMaxLength(1000); builder.Property(e => e.Theme) .HasMaxLength(500); builder.Property(e => e.Eligibility) .IsRequired() .HasMaxLength(200); builder.Property(e => e.SemifinalistActivity) .HasMaxLength(500); builder.Property(e => e.Documentation) .HasMaxLength(500); // Value conversions for enums builder.Property(e => e.EventFormat) .HasConversion() .HasMaxLength(50); // Ignore RelatedCareersText (not mapped to database) builder.Ignore(e => e.RelatedCareersText); // Many-to-many relationship with Career builder.HasMany(e => e.RelatedCareers) .WithMany() .UsingEntity(j => j.ToTable("EventDefinitionCareers")); } } }