feat(m9/T32a): SharedSchema entity + EF config + idempotent migration + repository
This commit is contained in:
+35
@@ -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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user