// src/Elecciones.Database/EleccionesDbContext.cs using Elecciones.Database.Entities; using Microsoft.EntityFrameworkCore; namespace Elecciones.Database; public class EleccionesDbContext(DbContextOptions options) : DbContext(options) { public DbSet AgrupacionesPoliticas { get; set; } public DbSet AmbitosGeograficos { get; set; } public DbSet ResultadosVotos { get; set; } public DbSet EstadosRecuentos { get; set; } public DbSet ProyeccionesBancas { get; set; } public DbSet Telegramas { get; set; } public DbSet ResumenesVotos { get; set; } public DbSet EstadosRecuentosGenerales { get; set; } public DbSet CategoriasElectorales { get; set; } protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); // Es buena práctica llamar a la base // Configuraciones adicionales del modelo (índices, etc.) pueden ir aquí. // Por ejemplo, para optimizar las búsquedas. modelBuilder.Entity() .HasIndex(r => new { r.AmbitoGeograficoId, r.AgrupacionPoliticaId }) .IsUnique(); modelBuilder.Entity(entity => { entity.Property(e => e.MesasTotalizadasPorcentaje).HasPrecision(5, 2); entity.Property(e => e.ParticipacionPorcentaje).HasPrecision(5, 2); }); modelBuilder.Entity() .Property(e => e.VotosPorcentaje).HasPrecision(5, 2); modelBuilder.Entity(entity => { entity.Property(e => e.MesasTotalizadasPorcentaje).HasPrecision(5, 2); entity.Property(e => e.ParticipacionPorcentaje).HasPrecision(5, 2); }); } }