Add Related Careers functionality to EventDefinition entity and update related components

Introduced a many-to-many relationship between EventDefinition and Career entities, allowing for the association of multiple careers with an event. Updated the AppDbContext to include a DbSet for Careers and modified the EventDefinitionConfiguration to handle the new relationship. Enhanced the Create, Edit, and Details components to support input and display of related careers, including normalization and processing logic for career names. Updated the database schema to reflect these changes.
This commit is contained in:
2025-12-28 15:22:03 -05:00
parent 8967d0f8a4
commit 06b2db0b4c
12 changed files with 788 additions and 18 deletions
@@ -0,0 +1,23 @@
using Core.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Data.Configurations
{
public class CareerConfiguration : IEntityTypeConfiguration<Career>
{
public void Configure(EntityTypeBuilder<Career> builder)
{
builder.HasKey(c => c.Id);
// Indexes
builder.HasIndex(c => c.Name).IsUnique();
// Constraints
builder.Property(c => c.Name)
.IsRequired()
.HasMaxLength(200);
}
}
}
@@ -38,10 +38,18 @@ namespace Data.Configurations
builder.Property(e => e.Documentation)
.HasMaxLength(500);
// Value conversions for enums
builder.Property(e => e.EventFormat)
.HasConversion<string>()
.HasMaxLength(50);
}
}
// Value conversions for enums
builder.Property(e => e.EventFormat)
.HasConversion<string>()
.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"));
}
}
}