using ODMO.Commons.Enums; using ODMO.Commons.DTOs.Events; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace ODMO.Infrastructure.ContextConfiguration.Arena { public class ArenaRankingConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { builder .ToTable("Ranking", "Arena") .HasKey(x => x.Id); builder .Property(x => x.Type) .HasColumnType("int") .HasConversion(new ValueConverter( x => (int)x, x => (ArenaRankingEnum)x)) .IsRequired(); builder .Property(x => x.StartDate) .HasColumnType("datetime2") .HasDefaultValueSql("getdate()") .IsRequired(); builder .Property(x => x.EndDate) .HasColumnType("datetime2") .HasDefaultValueSql("getdate()") .IsRequired(); builder .HasMany(x => x.Competitors) .WithOne(x => x.Ranking) .HasForeignKey(x => x.RankingId); } } }