1996b21961
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.
41 lines
1.1 KiB
C#
41 lines
1.1 KiB
C#
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);
|
|
}
|
|
}
|