using ControlCenter.Api.Configurations;
using ControlCenter.Api.Entities;
using Microsoft.EntityFrameworkCore;
namespace ControlCenter.Api.Data;
///
/// EF Core DbContext for the Control Center database.
/// All table and column names use snake_case via explicit HasColumnName configuration.
///
public class AppDbContext : DbContext
{
public AppDbContext(DbContextOptions options) : base(options) { }
public DbSet Agents => Set();
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
// Apply all entity type configurations from the Configurations namespace
modelBuilder.ApplyConfigurationsFromAssembly(typeof(AgentConfiguration).Assembly);
// Map the AgentStatus enum to a PostgreSQL enum type named "agent_status"
// This must be called after ApplyConfigurations to ensure the model is built
// before the enum mapping is applied.
modelBuilder.HasPostgresEnum();
base.OnModelCreating(modelBuilder);
}
}