feat(m9/T32a): SharedSchema entity + EF config + idempotent migration + repository

This commit is contained in:
Joseph Doherty
2026-06-18 11:26:48 -04:00
parent 48111b50fd
commit fbe4ddaf58
10 changed files with 2318 additions and 0 deletions
@@ -0,0 +1,35 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using ZB.MOM.WW.ScadaBridge.Commons.Entities.Schemas;
namespace ZB.MOM.WW.ScadaBridge.ConfigurationDatabase.Configurations;
/// <summary>
/// Maps the <see cref="SharedSchema"/> entity (M9 template-level JSON-Schema library,
/// Task T32a). Mirrors <c>SharedScriptConfiguration</c>: surrogate key, a UNIQUE index on
/// <see cref="SharedSchema.Name"/>, a bounded <see cref="SharedSchema.Scope"/>, and an
/// unbounded (<c>nvarchar(max)</c>) <see cref="SharedSchema.SchemaJson"/> body.
/// Auto-discovered by <c>ApplyConfigurationsFromAssembly</c> in <c>ScadaBridgeDbContext</c>.
/// </summary>
public class SharedSchemaConfiguration : IEntityTypeConfiguration<SharedSchema>
{
/// <summary>Configures the EF Core mapping for the <see cref="SharedSchema"/> entity.</summary>
/// <param name="builder">Entity type builder used to apply the configuration.</param>
public void Configure(EntityTypeBuilder<SharedSchema> builder)
{
builder.HasKey(s => s.Id);
builder.Property(s => s.Name)
.IsRequired()
.HasMaxLength(200);
builder.Property(s => s.Scope)
.HasMaxLength(200);
// Unbounded JSON Schema document body (nvarchar(max)) — no length cap, like SharedScript.Code.
builder.Property(s => s.SchemaJson)
.IsRequired();
builder.HasIndex(s => s.Name).IsUnique();
}
}