826eac1372
1. Separate configuration files 2. Remove commented code 3. Improve entity configurations (constraints, indexes, relationships)
48 lines
1.3 KiB
C#
48 lines
1.3 KiB
C#
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);
|
|
}
|
|
}
|
|
}
|