Phase 1 WP-1: EF Core DbContext with Fluent API mappings for all 26 entities

ScadaLinkDbContext with 10 configuration classes (Fluent API only), initial
migration creating 25 tables, environment-aware migration helper (auto-apply
dev, validate-only prod), DesignTimeDbContextFactory, optimistic concurrency
on DeploymentRecord. 20 tests verify schema, CRUD, relationships, cascades.
This commit is contained in:
Joseph Doherty
2026-03-16 19:15:50 -04:00
parent 9bc5a5163f
commit 1996b21961
23 changed files with 4494 additions and 9 deletions

View File

@@ -1,12 +1,29 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
namespace ScadaLink.ConfigurationDatabase;
public static class ServiceCollectionExtensions
{
/// <summary>
/// Registers the ScadaLinkDbContext with the provided SQL Server connection string.
/// </summary>
public static IServiceCollection AddConfigurationDatabase(this IServiceCollection services, string connectionString)
{
services.AddDbContext<ScadaLinkDbContext>(options =>
options.UseSqlServer(connectionString));
return services;
}
/// <summary>
/// Registers the ScadaLinkDbContext with no connection string (for backward compatibility / Phase 0 stubs).
/// This overload is a no-op placeholder; callers should migrate to the overload that accepts a connection string.
/// </summary>
public static IServiceCollection AddConfigurationDatabase(this IServiceCollection services)
{
// Phase 0: skeleton only
// Retained for backward compatibility during migration.
// Site nodes do not use the configuration database, so this is intentionally a no-op.
return services;
}
}