Database improvement

1.  Separate configuration files
2.  Remove commented code
3.  Improve entity configurations (constraints, indexes, relationships)
This commit is contained in:
2025-12-04 08:09:01 -05:00
parent 2d5d075879
commit 826eac1372
8 changed files with 787 additions and 80 deletions
@@ -0,0 +1,47 @@
using Core.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Data.Configurations
{
public class EventDefinitionConfiguration : IEntityTypeConfiguration<EventDefinition>
{
public void Configure(EntityTypeBuilder<EventDefinition> 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<string>()
.HasMaxLength(50);
}
}
}