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
@@ -0,0 +1,40 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using ScadaLink.Commons.Entities.Audit;
namespace ScadaLink.ConfigurationDatabase.Configurations;
public class AuditLogEntryConfiguration : IEntityTypeConfiguration<AuditLogEntry>
{
public void Configure(EntityTypeBuilder<AuditLogEntry> builder)
{
builder.HasKey(a => a.Id);
builder.Property(a => a.User)
.IsRequired()
.HasMaxLength(200);
builder.Property(a => a.Action)
.IsRequired()
.HasMaxLength(100);
builder.Property(a => a.EntityType)
.IsRequired()
.HasMaxLength(200);
builder.Property(a => a.EntityId)
.IsRequired()
.HasMaxLength(200);
builder.Property(a => a.EntityName)
.IsRequired()
.HasMaxLength(200);
// Indexes for common query patterns
builder.HasIndex(a => a.Timestamp);
builder.HasIndex(a => a.User);
builder.HasIndex(a => a.EntityType);
builder.HasIndex(a => a.EntityId);
builder.HasIndex(a => a.Action);
}
}