// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using ZB.MOM.WW.OtOpcUa.Configuration;

#nullable disable

namespace ZB.MOM.WW.OtOpcUa.Configuration.Migrations
{
    [DbContext(typeof(OtOpcUaConfigDbContext))]
    [Migration("20260722125506_AddClusterNodeMaintenanceMode")]
    partial class AddClusterNodeMaintenanceMode
    {
        /// <inheritdoc />
        protected override void BuildTargetModel(ModelBuilder modelBuilder)
        {
#pragma warning disable 612, 618
            modelBuilder
                .HasAnnotation("ProductVersion", "10.0.7")
                .HasAnnotation("Relational:MaxIdentifierLength", 128);

            SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);

            modelBuilder.Entity("Microsoft.AspNetCore.DataProtection.EntityFrameworkCore.DataProtectionKey", b =>
                {
                    b.Property<int>("Id")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("int");

                    SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));

                    b.Property<string>("FriendlyName")
                        .HasColumnType("nvarchar(max)");

                    b.Property<string>("Xml")
                        .HasColumnType("nvarchar(max)");

                    b.HasKey("Id");

                    b.ToTable("DataProtectionKeys", (string)null);
                });

            modelBuilder.Entity("ZB.MOM.WW.OtOpcUa.Configuration.Entities.ClusterNode", b =>
                {
                    b.Property<string>("NodeId")
                        .HasMaxLength(64)
                        .HasColumnType("nvarchar(64)");

                    b.Property<int>("AkkaPort")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("int")
                        .HasDefaultValue(4053);

                    b.Property<string>("ApplicationUri")
                        .IsRequired()
                        .HasMaxLength(256)
                        .HasColumnType("nvarchar(256)");

                    b.Property<string>("ClusterId")
                        .IsRequired()
                        .HasMaxLength(64)
                        .HasColumnType("nvarchar(64)");

                    b.Property<DateTime>("CreatedAt")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("datetime2(3)")
                        .HasDefaultValueSql("SYSUTCDATETIME()");

                    b.Property<string>("CreatedBy")
                        .IsRequired()
                        .HasMaxLength(128)
                        .HasColumnType("nvarchar(128)");

                    b.Property<int>("DashboardPort")
                        .HasColumnType("int");

                    b.Property<string>("DriverConfigOverridesJson")
                        .HasColumnType("nvarchar(max)");

                    b.Property<bool>("Enabled")
                        .HasColumnType("bit");

                    b.Property<int?>("GrpcPort")
                        .HasColumnType("int");

                    b.Property<string>("Host")
                        .IsRequired()
                        .HasMaxLength(255)
                        .HasColumnType("nvarchar(255)");

                    b.Property<DateTime?>("LastSeenAt")
                        .HasColumnType("datetime2(3)");

                    b.Property<bool>("MaintenanceMode")
                        .HasColumnType("bit");

                    b.Property<int>("OpcUaPort")
                        .HasColumnType("int");

                    b.Property<byte>("ServiceLevelBase")
                        .HasColumnType("tinyint");

                    b.HasKey("NodeId");

                    b.HasIndex("ApplicationUri")
                        .IsUnique()
                        .HasDatabaseName("UX_ClusterNode_ApplicationUri");

                    b.HasIndex("ClusterId")
                        .HasDatabaseName("IX_ClusterNode_ClusterId");

                    b.ToTable("ClusterNode", (string)null);
                });

            modelBuilder.Entity("ZB.MOM.WW.OtOpcUa.Configuration.Entities.ClusterNodeCredential", b =>
                {
                    b.Property<Guid>("CredentialId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("uniqueidentifier")
                        .HasDefaultValueSql("NEWSEQUENTIALID()");

                    b.Property<DateTime>("CreatedAt")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("datetime2(3)")
                        .HasDefaultValueSql("SYSUTCDATETIME()");

                    b.Property<string>("CreatedBy")
                        .IsRequired()
                        .HasMaxLength(128)
                        .HasColumnType("nvarchar(128)");

                    b.Property<bool>("Enabled")
                        .HasColumnType("bit");

                    b.Property<string>("Kind")
                        .IsRequired()
                        .HasMaxLength(32)
                        .HasColumnType("nvarchar(32)");

                    b.Property<string>("NodeId")
                        .IsRequired()
                        .HasMaxLength(64)
                        .HasColumnType("nvarchar(64)");

                    b.Property<DateTime?>("RotatedAt")
                        .HasColumnType("datetime2(3)");

                    b.Property<string>("Value")
                        .IsRequired()
                        .HasMaxLength(512)
                        .HasColumnType("nvarchar(512)");

                    b.HasKey("CredentialId");

                    b.HasIndex("Kind", "Value")
                        .IsUnique()
                        .HasDatabaseName("UX_ClusterNodeCredential_Value")
                        .HasFilter("[Enabled] = 1");

                    b.HasIndex("NodeId", "Enabled")
                        .HasDatabaseName("IX_ClusterNodeCredential_NodeId");

                    b.ToTable("ClusterNodeCredential", (string)null);
                });

            modelBuilder.Entity("ZB.MOM.WW.OtOpcUa.Configuration.Entities.ConfigAuditLog", b =>
                {
                    b.Property<long>("AuditId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("bigint");

                    SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("AuditId"));

                    b.Property<string>("ClusterId")
                        .HasMaxLength(64)
                        .HasColumnType("nvarchar(64)");

                    b.Property<Guid?>("CorrelationId")
                        .HasColumnType("uniqueidentifier");

                    b.Property<string>("DetailsJson")
                        .HasColumnType("nvarchar(max)");

                    b.Property<Guid?>("EventId")
                        .HasColumnType("uniqueidentifier");

                    b.Property<string>("EventType")
                        .IsRequired()
                        .HasMaxLength(64)
                        .HasColumnType("nvarchar(64)");

                    b.Property<long?>("GenerationId")
                        .HasColumnType("bigint");

                    b.Property<string>("NodeId")
                        .HasMaxLength(64)
                        .HasColumnType("nvarchar(64)");

                    b.Property<string>("Outcome")
                        .HasMaxLength(16)
                        .HasColumnType("nvarchar(16)");

                    b.Property<string>("Principal")
                        .IsRequired()
                        .HasMaxLength(128)
                        .HasColumnType("nvarchar(128)");

                    b.Property<DateTime>("Timestamp")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("datetime2(3)")
                        .HasDefaultValueSql("SYSUTCDATETIME()");

                    b.HasKey("AuditId");

                    b.HasIndex("EventId")
                        .IsUnique()
                        .HasDatabaseName("UX_ConfigAuditLog_EventId")
                        .HasFilter("[EventId] IS NOT NULL");

                    b.HasIndex("GenerationId")
                        .HasDatabaseName("IX_ConfigAuditLog_Generation")
                        .HasFilter("[GenerationId] IS NOT NULL");

                    b.HasIndex("ClusterId", "Timestamp")
                        .IsDescending(false, true)
                        .HasDatabaseName("IX_ConfigAuditLog_Cluster_Time");

                    b.ToTable("ConfigAuditLog", null, t =>
                        {
                            t.HasCheckConstraint("CK_ConfigAuditLog_DetailsJson_IsJson", "DetailsJson IS NULL OR ISJSON(DetailsJson) = 1");
                        });
                });

            modelBuilder.Entity("ZB.MOM.WW.OtOpcUa.Configuration.Entities.ConfigEdit", b =>
                {
                    b.Property<Guid>("EditId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("uniqueidentifier")
                        .HasDefaultValueSql("NEWSEQUENTIALID()");

                    b.Property<DateTime>("EditedAtUtc")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("datetime2(3)")
                        .HasDefaultValueSql("SYSUTCDATETIME()");

                    b.Property<string>("EditedBy")
                        .IsRequired()
                        .HasMaxLength(128)
                        .HasColumnType("nvarchar(128)");

                    b.Property<Guid>("EntityId")
                        .HasColumnType("uniqueidentifier");

                    b.Property<string>("EntityType")
                        .IsRequired()
                        .HasMaxLength(64)
                        .HasColumnType("nvarchar(64)");

                    b.Property<Guid?>("ExecutionId")
                        .HasColumnType("uniqueidentifier");

                    b.Property<string>("FieldsJson")
                        .IsRequired()
                        .HasColumnType("nvarchar(max)");

                    b.Property<string>("SourceNode")
                        .IsRequired()
                        .HasMaxLength(64)
                        .HasColumnType("nvarchar(64)");

                    b.HasKey("EditId");

                    b.HasIndex("EditedAtUtc")
                        .HasDatabaseName("IX_ConfigEdit_EditedAt");

                    b.HasIndex("ExecutionId")
                        .HasDatabaseName("IX_ConfigEdit_Execution")
                        .HasFilter("[ExecutionId] IS NOT NULL");

                    b.HasIndex("EntityType", "EntityId")
                        .HasDatabaseName("IX_ConfigEdit_Entity");

                    b.ToTable("ConfigEdit", null, t =>
                        {
                            t.HasCheckConstraint("CK_ConfigEdit_FieldsJson_IsJson", "ISJSON(FieldsJson) = 1");
                        });
                });

            modelBuilder.Entity("ZB.MOM.WW.OtOpcUa.Configuration.Entities.Deployment", b =>
                {
                    b.Property<Guid>("DeploymentId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("uniqueidentifier")
                        .HasDefaultValueSql("NEWSEQUENTIALID()");

                    b.Property<byte[]>("ArtifactBlob")
                        .IsRequired()
                        .HasColumnType("varbinary(max)");

                    b.Property<DateTime>("CreatedAtUtc")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("datetime2(3)")
                        .HasDefaultValueSql("SYSUTCDATETIME()");

                    b.Property<string>("CreatedBy")
                        .IsRequired()
                        .HasMaxLength(128)
                        .HasColumnType("nvarchar(128)");

                    b.Property<string>("FailureReason")
                        .HasMaxLength(2048)
                        .HasColumnType("nvarchar(2048)");

                    b.Property<string>("RevisionHash")
                        .IsRequired()
                        .HasMaxLength(64)
                        .HasColumnType("nvarchar(64)");

                    b.Property<byte[]>("RowVersion")
                        .IsConcurrencyToken()
                        .IsRequired()
                        .ValueGeneratedOnAddOrUpdate()
                        .HasColumnType("rowversion");

                    b.Property<DateTime?>("SealedAtUtc")
                        .HasColumnType("datetime2(3)");

                    b.Property<int>("Status")
                        .HasColumnType("int");

                    b.HasKey("DeploymentId");

                    b.HasIndex("CreatedAtUtc")
                        .HasDatabaseName("IX_Deployment_CreatedAt");

                    b.HasIndex("Status")
                        .HasDatabaseName("IX_Deployment_Status");

                    b.ToTable("Deployment", (string)null);
                });

            modelBuilder.Entity("ZB.MOM.WW.OtOpcUa.Configuration.Entities.Device", b =>
                {
                    b.Property<Guid>("DeviceRowId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("uniqueidentifier")
                        .HasDefaultValueSql("NEWSEQUENTIALID()");

                    b.Property<string>("DeviceConfig")
                        .IsRequired()
                        .HasColumnType("nvarchar(max)");

                    b.Property<string>("DeviceId")
                        .HasMaxLength(64)
                        .HasColumnType("nvarchar(64)");

                    b.Property<string>("DriverInstanceId")
                        .IsRequired()
                        .HasMaxLength(64)
                        .HasColumnType("nvarchar(64)");

                    b.Property<bool>("Enabled")
                        .HasColumnType("bit");

                    b.Property<string>("Name")
                        .IsRequired()
                        .HasMaxLength(128)
                        .HasColumnType("nvarchar(128)");

                    b.Property<byte[]>("RowVersion")
                        .IsConcurrencyToken()
                        .IsRequired()
                        .ValueGeneratedOnAddOrUpdate()
                        .HasColumnType("rowversion");

                    b.HasKey("DeviceRowId");

                    b.HasIndex("DeviceId")
                        .IsUnique()
                        .HasDatabaseName("UX_Device_LogicalId")
                        .HasFilter("[DeviceId] IS NOT NULL");

                    b.HasIndex("DriverInstanceId")
                        .HasDatabaseName("IX_Device_Driver");

                    b.HasIndex("DriverInstanceId", "Name")
                        .IsUnique()
                        .HasDatabaseName("UX_Device_Driver_Name");

                    b.ToTable("Device", null, t =>
                        {
                            t.HasCheckConstraint("CK_Device_DeviceConfig_IsJson", "ISJSON(DeviceConfig) = 1");
                        });
                });

            modelBuilder.Entity("ZB.MOM.WW.OtOpcUa.Configuration.Entities.DriverHostStatus", b =>
                {
                    b.Property<string>("NodeId")
                        .HasMaxLength(64)
                        .HasColumnType("nvarchar(64)");

                    b.Property<string>("DriverInstanceId")
                        .HasMaxLength(64)
                        .HasColumnType("nvarchar(64)");

                    b.Property<string>("HostName")
                        .HasMaxLength(256)
                        .HasColumnType("nvarchar(256)");

                    b.Property<string>("Detail")
                        .HasMaxLength(1024)
                        .HasColumnType("nvarchar(1024)");

                    b.Property<DateTime>("LastSeenUtc")
                        .HasColumnType("datetime2(3)");

                    b.Property<string>("State")
                        .IsRequired()
                        .HasMaxLength(16)
                        .HasColumnType("nvarchar(16)");

                    b.Property<DateTime>("StateChangedUtc")
                        .HasColumnType("datetime2(3)");

                    b.HasKey("NodeId", "DriverInstanceId", "HostName");

                    b.HasIndex("LastSeenUtc")
                        .HasDatabaseName("IX_DriverHostStatus_LastSeen");

                    b.HasIndex("NodeId")
                        .HasDatabaseName("IX_DriverHostStatus_Node");

                    b.ToTable("DriverHostStatus", (string)null);
                });

            modelBuilder.Entity("ZB.MOM.WW.OtOpcUa.Configuration.Entities.DriverInstance", b =>
                {
                    b.Property<Guid>("DriverInstanceRowId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("uniqueidentifier")
                        .HasDefaultValueSql("NEWSEQUENTIALID()");

                    b.Property<string>("ClusterId")
                        .IsRequired()
                        .HasMaxLength(64)
                        .HasColumnType("nvarchar(64)");

                    b.Property<string>("DriverConfig")
                        .IsRequired()
                        .HasColumnType("nvarchar(max)");

                    b.Property<string>("DriverInstanceId")
                        .HasMaxLength(64)
                        .HasColumnType("nvarchar(64)");

                    b.Property<string>("DriverType")
                        .IsRequired()
                        .HasMaxLength(32)
                        .HasColumnType("nvarchar(32)");

                    b.Property<bool>("Enabled")
                        .HasColumnType("bit");

                    b.Property<string>("Name")
                        .IsRequired()
                        .HasMaxLength(128)
                        .HasColumnType("nvarchar(128)");

                    b.Property<string>("RawFolderId")
                        .HasMaxLength(64)
                        .HasColumnType("nvarchar(64)");

                    b.Property<string>("ResilienceConfig")
                        .HasColumnType("nvarchar(max)");

                    b.Property<byte[]>("RowVersion")
                        .IsConcurrencyToken()
                        .IsRequired()
                        .ValueGeneratedOnAddOrUpdate()
                        .HasColumnType("rowversion");

                    b.HasKey("DriverInstanceRowId");

                    b.HasIndex("ClusterId")
                        .HasDatabaseName("IX_DriverInstance_Cluster");

                    b.HasIndex("DriverInstanceId")
                        .IsUnique()
                        .HasDatabaseName("UX_DriverInstance_LogicalId")
                        .HasFilter("[DriverInstanceId] IS NOT NULL");

                    b.HasIndex("RawFolderId")
                        .HasDatabaseName("IX_DriverInstance_RawFolder");

                    b.HasIndex("ClusterId", "Name")
                        .IsUnique()
                        .HasDatabaseName("UX_DriverInstance_ClusterRoot_Name")
                        .HasFilter("[RawFolderId] IS NULL");

                    b.HasIndex("ClusterId", "RawFolderId", "Name")
                        .IsUnique()
                        .HasDatabaseName("UX_DriverInstance_Folder_Name")
                        .HasFilter("[RawFolderId] IS NOT NULL");

                    b.ToTable("DriverInstance", null, t =>
                        {
                            t.HasCheckConstraint("CK_DriverInstance_DriverConfig_IsJson", "ISJSON(DriverConfig) = 1");

                            t.HasCheckConstraint("CK_DriverInstance_ResilienceConfig_IsJson", "ResilienceConfig IS NULL OR ISJSON(ResilienceConfig) = 1");
                        });
                });

            modelBuilder.Entity("ZB.MOM.WW.OtOpcUa.Configuration.Entities.DriverInstanceResilienceStatus", b =>
                {
                    b.Property<string>("DriverInstanceId")
                        .HasMaxLength(64)
                        .HasColumnType("nvarchar(64)");

                    b.Property<string>("HostName")
                        .HasMaxLength(256)
                        .HasColumnType("nvarchar(256)");

                    b.Property<long>("BaselineFootprintBytes")
                        .HasColumnType("bigint");

                    b.Property<int>("ConsecutiveFailures")
                        .HasColumnType("int");

                    b.Property<int>("CurrentBulkheadDepth")
                        .HasColumnType("int");

                    b.Property<long>("CurrentFootprintBytes")
                        .HasColumnType("bigint");

                    b.Property<DateTime?>("LastCircuitBreakerOpenUtc")
                        .HasColumnType("datetime2(3)");

                    b.Property<DateTime?>("LastRecycleUtc")
                        .HasColumnType("datetime2(3)");

                    b.Property<DateTime>("LastSampledUtc")
                        .HasColumnType("datetime2(3)");

                    b.HasKey("DriverInstanceId", "HostName");

                    b.HasIndex("LastSampledUtc")
                        .HasDatabaseName("IX_DriverResilience_LastSampled");

                    b.ToTable("DriverInstanceResilienceStatus", (string)null);
                });

            modelBuilder.Entity("ZB.MOM.WW.OtOpcUa.Configuration.Entities.Equipment", b =>
                {
                    b.Property<Guid>("EquipmentRowId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("uniqueidentifier")
                        .HasDefaultValueSql("NEWSEQUENTIALID()");

                    b.Property<string>("AssetLocation")
                        .HasMaxLength(256)
                        .HasColumnType("nvarchar(256)");

                    b.Property<string>("DeviceManualUri")
                        .HasMaxLength(512)
                        .HasColumnType("nvarchar(512)");

                    b.Property<bool>("Enabled")
                        .HasColumnType("bit");

                    b.Property<string>("EquipmentClassRef")
                        .HasMaxLength(128)
                        .HasColumnType("nvarchar(128)");

                    b.Property<string>("EquipmentId")
                        .HasMaxLength(64)
                        .HasColumnType("nvarchar(64)");

                    b.Property<Guid>("EquipmentUuid")
                        .HasColumnType("uniqueidentifier");

                    b.Property<string>("HardwareRevision")
                        .HasMaxLength(32)
                        .HasColumnType("nvarchar(32)");

                    b.Property<string>("MachineCode")
                        .IsRequired()
                        .HasMaxLength(64)
                        .HasColumnType("nvarchar(64)");

                    b.Property<string>("Manufacturer")
                        .HasMaxLength(64)
                        .HasColumnType("nvarchar(64)");

                    b.Property<string>("ManufacturerUri")
                        .HasMaxLength(512)
                        .HasColumnType("nvarchar(512)");

                    b.Property<string>("Model")
                        .HasMaxLength(64)
                        .HasColumnType("nvarchar(64)");

                    b.Property<string>("Name")
                        .IsRequired()
                        .HasMaxLength(32)
                        .HasColumnType("nvarchar(32)");

                    b.Property<byte[]>("RowVersion")
                        .IsConcurrencyToken()
                        .IsRequired()
                        .ValueGeneratedOnAddOrUpdate()
                        .HasColumnType("rowversion");

                    b.Property<string>("SAPID")
                        .HasMaxLength(64)
                        .HasColumnType("nvarchar(64)");

                    b.Property<string>("SerialNumber")
                        .HasMaxLength(64)
                        .HasColumnType("nvarchar(64)");

                    b.Property<string>("SoftwareRevision")
                        .HasMaxLength(32)
                        .HasColumnType("nvarchar(32)");

                    b.Property<string>("UnsLineId")
                        .IsRequired()
                        .HasMaxLength(64)
                        .HasColumnType("nvarchar(64)");

                    b.Property<short?>("YearOfConstruction")
                        .HasColumnType("smallint");

                    b.Property<string>("ZTag")
                        .HasMaxLength(64)
                        .HasColumnType("nvarchar(64)");

                    b.HasKey("EquipmentRowId");

                    b.HasIndex("EquipmentId")
                        .IsUnique()
                        .HasDatabaseName("UX_Equipment_LogicalId")
                        .HasFilter("[EquipmentId] IS NOT NULL");

                    b.HasIndex("EquipmentUuid")
                        .IsUnique()
                        .HasDatabaseName("UX_Equipment_Uuid");

                    b.HasIndex("MachineCode")
                        .HasDatabaseName("IX_Equipment_MachineCode");

                    b.HasIndex("SAPID")
                        .HasDatabaseName("IX_Equipment_SAPID")
                        .HasFilter("[SAPID] IS NOT NULL");

                    b.HasIndex("UnsLineId")
                        .HasDatabaseName("IX_Equipment_Line");

                    b.HasIndex("ZTag")
                        .HasDatabaseName("IX_Equipment_ZTag")
                        .HasFilter("[ZTag] IS NOT NULL");

                    b.HasIndex("UnsLineId", "Name")
                        .IsUnique()
                        .HasDatabaseName("UX_Equipment_LinePath");

                    b.ToTable("Equipment", (string)null);
                });

            modelBuilder.Entity("ZB.MOM.WW.OtOpcUa.Configuration.Entities.ExternalIdReservation", b =>
                {
                    b.Property<Guid>("ReservationId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("uniqueidentifier")
                        .HasDefaultValueSql("NEWSEQUENTIALID()");

                    b.Property<string>("ClusterId")
                        .IsRequired()
                        .HasMaxLength(64)
                        .HasColumnType("nvarchar(64)");

                    b.Property<Guid>("EquipmentUuid")
                        .HasColumnType("uniqueidentifier");

                    b.Property<DateTime>("FirstPublishedAt")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("datetime2(3)")
                        .HasDefaultValueSql("SYSUTCDATETIME()");

                    b.Property<string>("FirstPublishedBy")
                        .IsRequired()
                        .HasMaxLength(128)
                        .HasColumnType("nvarchar(128)");

                    b.Property<string>("Kind")
                        .IsRequired()
                        .HasMaxLength(16)
                        .HasColumnType("nvarchar(16)");

                    b.Property<DateTime>("LastPublishedAt")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("datetime2(3)")
                        .HasDefaultValueSql("SYSUTCDATETIME()");

                    b.Property<string>("ReleaseReason")
                        .HasMaxLength(512)
                        .HasColumnType("nvarchar(512)");

                    b.Property<DateTime?>("ReleasedAt")
                        .HasColumnType("datetime2(3)");

                    b.Property<string>("ReleasedBy")
                        .HasMaxLength(128)
                        .HasColumnType("nvarchar(128)");

                    b.Property<string>("Value")
                        .IsRequired()
                        .HasMaxLength(64)
                        .HasColumnType("nvarchar(64)");

                    b.HasKey("ReservationId");

                    b.HasIndex("EquipmentUuid")
                        .HasDatabaseName("IX_ExternalIdReservation_Equipment");

                    b.HasIndex("Kind", "Value")
                        .IsUnique()
                        .HasDatabaseName("UX_ExternalIdReservation_KindValue_Active")
                        .HasFilter("[ReleasedAt] IS NULL");

                    b.ToTable("ExternalIdReservation", (string)null);
                });

            modelBuilder.Entity("ZB.MOM.WW.OtOpcUa.Configuration.Entities.LdapGroupRoleMapping", b =>
                {
                    b.Property<Guid>("Id")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("uniqueidentifier");

                    b.Property<string>("ClusterId")
                        .HasMaxLength(64)
                        .HasColumnType("nvarchar(64)");

                    b.Property<DateTime>("CreatedAtUtc")
                        .HasColumnType("datetime2(3)");

                    b.Property<bool>("IsSystemWide")
                        .HasColumnType("bit");

                    b.Property<string>("LdapGroup")
                        .IsRequired()
                        .HasMaxLength(512)
                        .HasColumnType("nvarchar(512)");

                    b.Property<string>("Notes")
                        .HasMaxLength(512)
                        .HasColumnType("nvarchar(512)");

                    b.Property<string>("Role")
                        .IsRequired()
                        .HasMaxLength(32)
                        .HasColumnType("nvarchar(32)");

                    b.HasKey("Id");

                    b.HasIndex("ClusterId");

                    b.HasIndex("LdapGroup")
                        .HasDatabaseName("IX_LdapGroupRoleMapping_Group");

                    b.HasIndex("LdapGroup", "ClusterId")
                        .IsUnique()
                        .HasDatabaseName("UX_LdapGroupRoleMapping_Group_Cluster")
                        .HasFilter("[ClusterId] IS NOT NULL");

                    b.ToTable("LdapGroupRoleMapping", (string)null);
                });

            modelBuilder.Entity("ZB.MOM.WW.OtOpcUa.Configuration.Entities.NodeAcl", b =>
                {
                    b.Property<Guid>("NodeAclRowId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("uniqueidentifier")
                        .HasDefaultValueSql("NEWSEQUENTIALID()");

                    b.Property<string>("ClusterId")
                        .IsRequired()
                        .HasMaxLength(64)
                        .HasColumnType("nvarchar(64)");

                    b.Property<string>("LdapGroup")
                        .IsRequired()
                        .HasMaxLength(256)
                        .HasColumnType("nvarchar(256)");

                    b.Property<string>("NodeAclId")
                        .HasMaxLength(64)
                        .HasColumnType("nvarchar(64)");

                    b.Property<string>("Notes")
                        .HasMaxLength(512)
                        .HasColumnType("nvarchar(512)");

                    b.Property<int>("PermissionFlags")
                        .HasColumnType("int");

                    b.Property<byte[]>("RowVersion")
                        .IsConcurrencyToken()
                        .IsRequired()
                        .ValueGeneratedOnAddOrUpdate()
                        .HasColumnType("rowversion");

                    b.Property<string>("ScopeId")
                        .HasMaxLength(64)
                        .HasColumnType("nvarchar(64)");

                    b.Property<string>("ScopeKind")
                        .IsRequired()
                        .HasMaxLength(16)
                        .HasColumnType("nvarchar(16)");

                    b.HasKey("NodeAclRowId");

                    b.HasIndex("ClusterId")
                        .HasDatabaseName("IX_NodeAcl_Cluster");

                    b.HasIndex("LdapGroup")
                        .HasDatabaseName("IX_NodeAcl_Group");

                    b.HasIndex("NodeAclId")
                        .IsUnique()
                        .HasDatabaseName("UX_NodeAcl_LogicalId")
                        .HasFilter("[NodeAclId] IS NOT NULL");

                    b.HasIndex("ScopeKind", "ScopeId")
                        .HasDatabaseName("IX_NodeAcl_Scope")
                        .HasFilter("[ScopeId] IS NOT NULL");

                    b.HasIndex("ClusterId", "LdapGroup", "ScopeKind", "ScopeId")
                        .IsUnique()
                        .HasDatabaseName("UX_NodeAcl_GroupScope")
                        .HasFilter("[ScopeId] IS NOT NULL");

                    b.ToTable("NodeAcl", (string)null);
                });

            modelBuilder.Entity("ZB.MOM.WW.OtOpcUa.Configuration.Entities.NodeDeploymentState", b =>
                {
                    b.Property<string>("NodeId")
                        .HasMaxLength(64)
                        .HasColumnType("nvarchar(64)");

                    b.Property<Guid>("DeploymentId")
                        .HasColumnType("uniqueidentifier");

                    b.Property<DateTime?>("AppliedAtUtc")
                        .HasColumnType("datetime2(3)");

                    b.Property<string>("FailureReason")
                        .HasMaxLength(2048)
                        .HasColumnType("nvarchar(2048)");

                    b.Property<byte[]>("RowVersion")
                        .IsConcurrencyToken()
                        .IsRequired()
                        .ValueGeneratedOnAddOrUpdate()
                        .HasColumnType("rowversion");

                    b.Property<DateTime>("StartedAtUtc")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("datetime2(3)")
                        .HasDefaultValueSql("SYSUTCDATETIME()");

                    b.Property<int>("Status")
                        .HasColumnType("int");

                    b.HasKey("NodeId", "DeploymentId");

                    b.HasIndex("DeploymentId")
                        .HasDatabaseName("IX_NodeDeploymentState_Deployment");

                    b.HasIndex("Status")
                        .HasDatabaseName("IX_NodeDeploymentState_Status");

                    b.ToTable("NodeDeploymentState", (string)null);
                });

            modelBuilder.Entity("ZB.MOM.WW.OtOpcUa.Configuration.Entities.PollGroup", b =>
                {
                    b.Property<Guid>("PollGroupRowId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("uniqueidentifier")
                        .HasDefaultValueSql("NEWSEQUENTIALID()");

                    b.Property<string>("DriverInstanceId")
                        .IsRequired()
                        .HasMaxLength(64)
                        .HasColumnType("nvarchar(64)");

                    b.Property<int>("IntervalMs")
                        .HasColumnType("int");

                    b.Property<string>("Name")
                        .IsRequired()
                        .HasMaxLength(128)
                        .HasColumnType("nvarchar(128)");

                    b.Property<string>("PollGroupId")
                        .HasMaxLength(64)
                        .HasColumnType("nvarchar(64)");

                    b.Property<byte[]>("RowVersion")
                        .IsConcurrencyToken()
                        .IsRequired()
                        .ValueGeneratedOnAddOrUpdate()
                        .HasColumnType("rowversion");

                    b.HasKey("PollGroupRowId");

                    b.HasIndex("DriverInstanceId")
                        .HasDatabaseName("IX_PollGroup_Driver");

                    b.HasIndex("PollGroupId")
                        .IsUnique()
                        .HasDatabaseName("UX_PollGroup_LogicalId")
                        .HasFilter("[PollGroupId] IS NOT NULL");

                    b.ToTable("PollGroup", null, t =>
                        {
                            t.HasCheckConstraint("CK_PollGroup_IntervalMs_Min", "IntervalMs >= 50");
                        });
                });

            modelBuilder.Entity("ZB.MOM.WW.OtOpcUa.Configuration.Entities.RawFolder", b =>
                {
                    b.Property<Guid>("RawFolderRowId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("uniqueidentifier")
                        .HasDefaultValueSql("NEWSEQUENTIALID()");

                    b.Property<string>("ClusterId")
                        .IsRequired()
                        .HasMaxLength(64)
                        .HasColumnType("nvarchar(64)");

                    b.Property<string>("Name")
                        .IsRequired()
                        .HasMaxLength(128)
                        .HasColumnType("nvarchar(128)");

                    b.Property<string>("ParentRawFolderId")
                        .HasMaxLength(64)
                        .HasColumnType("nvarchar(64)");

                    b.Property<string>("RawFolderId")
                        .HasMaxLength(64)
                        .HasColumnType("nvarchar(64)");

                    b.Property<byte[]>("RowVersion")
                        .IsConcurrencyToken()
                        .IsRequired()
                        .ValueGeneratedOnAddOrUpdate()
                        .HasColumnType("rowversion");

                    b.Property<int>("SortOrder")
                        .HasColumnType("int");

                    b.HasKey("RawFolderRowId");

                    b.HasIndex("ClusterId")
                        .HasDatabaseName("IX_RawFolder_Cluster");

                    b.HasIndex("RawFolderId")
                        .IsUnique()
                        .HasDatabaseName("UX_RawFolder_LogicalId")
                        .HasFilter("[RawFolderId] IS NOT NULL");

                    b.HasIndex("ClusterId", "Name")
                        .IsUnique()
                        .HasDatabaseName("UX_RawFolder_ClusterRoot_Name")
                        .HasFilter("[ParentRawFolderId] IS NULL");

                    b.HasIndex("ClusterId", "ParentRawFolderId", "Name")
                        .IsUnique()
                        .HasDatabaseName("UX_RawFolder_Parent_Name")
                        .HasFilter("[ParentRawFolderId] IS NOT NULL");

                    b.ToTable("RawFolder", (string)null);
                });

            modelBuilder.Entity("ZB.MOM.WW.OtOpcUa.Configuration.Entities.Script", b =>
                {
                    b.Property<Guid>("ScriptRowId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("uniqueidentifier")
                        .HasDefaultValueSql("NEWSEQUENTIALID()");

                    b.Property<string>("Language")
                        .IsRequired()
                        .HasMaxLength(16)
                        .HasColumnType("nvarchar(16)");

                    b.Property<string>("Name")
                        .IsRequired()
                        .HasMaxLength(128)
                        .HasColumnType("nvarchar(128)");

                    b.Property<byte[]>("RowVersion")
                        .IsConcurrencyToken()
                        .IsRequired()
                        .ValueGeneratedOnAddOrUpdate()
                        .HasColumnType("rowversion");

                    b.Property<string>("ScriptId")
                        .HasMaxLength(64)
                        .HasColumnType("nvarchar(64)");

                    b.Property<string>("SourceCode")
                        .IsRequired()
                        .HasColumnType("nvarchar(max)");

                    b.Property<string>("SourceHash")
                        .IsRequired()
                        .HasMaxLength(64)
                        .HasColumnType("nvarchar(64)");

                    b.HasKey("ScriptRowId");

                    b.HasIndex("ScriptId")
                        .IsUnique()
                        .HasDatabaseName("UX_Script_LogicalId")
                        .HasFilter("[ScriptId] IS NOT NULL");

                    b.HasIndex("SourceHash")
                        .HasDatabaseName("IX_Script_SourceHash");

                    b.ToTable("Script", (string)null);
                });

            modelBuilder.Entity("ZB.MOM.WW.OtOpcUa.Configuration.Entities.ScriptedAlarm", b =>
                {
                    b.Property<Guid>("ScriptedAlarmRowId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("uniqueidentifier")
                        .HasDefaultValueSql("NEWSEQUENTIALID()");

                    b.Property<string>("AlarmType")
                        .IsRequired()
                        .HasMaxLength(32)
                        .HasColumnType("nvarchar(32)");

                    b.Property<bool>("Enabled")
                        .HasColumnType("bit");

                    b.Property<string>("EquipmentId")
                        .IsRequired()
                        .HasMaxLength(64)
                        .HasColumnType("nvarchar(64)");

                    b.Property<bool>("HistorizeToAveva")
                        .HasColumnType("bit");

                    b.Property<string>("MessageTemplate")
                        .IsRequired()
                        .HasMaxLength(1024)
                        .HasColumnType("nvarchar(1024)");

                    b.Property<string>("Name")
                        .IsRequired()
                        .HasMaxLength(128)
                        .HasColumnType("nvarchar(128)");

                    b.Property<string>("PredicateScriptId")
                        .IsRequired()
                        .HasMaxLength(64)
                        .HasColumnType("nvarchar(64)");

                    b.Property<bool>("Retain")
                        .HasColumnType("bit");

                    b.Property<byte[]>("RowVersion")
                        .IsConcurrencyToken()
                        .IsRequired()
                        .ValueGeneratedOnAddOrUpdate()
                        .HasColumnType("rowversion");

                    b.Property<string>("ScriptedAlarmId")
                        .HasMaxLength(64)
                        .HasColumnType("nvarchar(64)");

                    b.Property<int>("Severity")
                        .HasColumnType("int");

                    b.HasKey("ScriptedAlarmRowId");

                    b.HasIndex("PredicateScriptId")
                        .HasDatabaseName("IX_ScriptedAlarm_Script");

                    b.HasIndex("ScriptedAlarmId")
                        .IsUnique()
                        .HasDatabaseName("UX_ScriptedAlarm_LogicalId")
                        .HasFilter("[ScriptedAlarmId] IS NOT NULL");

                    b.HasIndex("EquipmentId", "Name")
                        .IsUnique()
                        .HasDatabaseName("UX_ScriptedAlarm_EquipmentPath");

                    b.ToTable("ScriptedAlarm", null, t =>
                        {
                            t.HasCheckConstraint("CK_ScriptedAlarm_AlarmType", "AlarmType IN ('AlarmCondition','LimitAlarm','OffNormalAlarm','DiscreteAlarm')");

                            t.HasCheckConstraint("CK_ScriptedAlarm_Severity_Range", "Severity BETWEEN 1 AND 1000");
                        });
                });

            modelBuilder.Entity("ZB.MOM.WW.OtOpcUa.Configuration.Entities.ScriptedAlarmState", b =>
                {
                    b.Property<string>("ScriptedAlarmId")
                        .HasMaxLength(64)
                        .HasColumnType("nvarchar(64)");

                    b.Property<string>("AckedState")
                        .IsRequired()
                        .HasMaxLength(16)
                        .HasColumnType("nvarchar(16)");

                    b.Property<string>("CommentsJson")
                        .IsRequired()
                        .HasColumnType("nvarchar(max)");

                    b.Property<string>("ConfirmedState")
                        .IsRequired()
                        .HasMaxLength(16)
                        .HasColumnType("nvarchar(16)");

                    b.Property<string>("EnabledState")
                        .IsRequired()
                        .HasMaxLength(16)
                        .HasColumnType("nvarchar(16)");

                    b.Property<string>("LastAckComment")
                        .HasMaxLength(1024)
                        .HasColumnType("nvarchar(1024)");

                    b.Property<string>("LastAckUser")
                        .HasMaxLength(128)
                        .HasColumnType("nvarchar(128)");

                    b.Property<DateTime?>("LastAckUtc")
                        .HasColumnType("datetime2(3)");

                    b.Property<string>("LastConfirmComment")
                        .HasMaxLength(1024)
                        .HasColumnType("nvarchar(1024)");

                    b.Property<string>("LastConfirmUser")
                        .HasMaxLength(128)
                        .HasColumnType("nvarchar(128)");

                    b.Property<DateTime?>("LastConfirmUtc")
                        .HasColumnType("datetime2(3)");

                    b.Property<DateTime?>("ShelvingExpiresUtc")
                        .HasColumnType("datetime2(3)");

                    b.Property<string>("ShelvingState")
                        .IsRequired()
                        .HasMaxLength(16)
                        .HasColumnType("nvarchar(16)");

                    b.Property<DateTime>("UpdatedAtUtc")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("datetime2(3)")
                        .HasDefaultValueSql("SYSUTCDATETIME()");

                    b.HasKey("ScriptedAlarmId");

                    b.ToTable("ScriptedAlarmState", null, t =>
                        {
                            t.HasCheckConstraint("CK_ScriptedAlarmState_CommentsJson_IsJson", "ISJSON(CommentsJson) = 1");
                        });
                });

            modelBuilder.Entity("ZB.MOM.WW.OtOpcUa.Configuration.Entities.ServerCluster", b =>
                {
                    b.Property<string>("ClusterId")
                        .HasMaxLength(64)
                        .HasColumnType("nvarchar(64)");

                    b.Property<DateTime>("CreatedAt")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("datetime2(3)")
                        .HasDefaultValueSql("SYSUTCDATETIME()");

                    b.Property<string>("CreatedBy")
                        .IsRequired()
                        .HasMaxLength(128)
                        .HasColumnType("nvarchar(128)");

                    b.Property<bool>("Enabled")
                        .HasColumnType("bit");

                    b.Property<string>("Enterprise")
                        .IsRequired()
                        .HasMaxLength(32)
                        .HasColumnType("nvarchar(32)");

                    b.Property<DateTime?>("ModifiedAt")
                        .HasColumnType("datetime2(3)");

                    b.Property<string>("ModifiedBy")
                        .HasMaxLength(128)
                        .HasColumnType("nvarchar(128)");

                    b.Property<string>("Name")
                        .IsRequired()
                        .HasMaxLength(128)
                        .HasColumnType("nvarchar(128)");

                    b.Property<byte>("NodeCount")
                        .HasColumnType("tinyint");

                    b.Property<string>("Notes")
                        .HasMaxLength(1024)
                        .HasColumnType("nvarchar(1024)");

                    b.Property<string>("RedundancyMode")
                        .IsRequired()
                        .HasMaxLength(16)
                        .HasColumnType("nvarchar(16)");

                    b.Property<string>("Site")
                        .IsRequired()
                        .HasMaxLength(32)
                        .HasColumnType("nvarchar(32)");

                    b.HasKey("ClusterId");

                    b.HasIndex("Name")
                        .IsUnique()
                        .HasDatabaseName("UX_ServerCluster_Name");

                    b.HasIndex("Site")
                        .HasDatabaseName("IX_ServerCluster_Site");

                    b.ToTable("ServerCluster", null, t =>
                        {
                            t.HasCheckConstraint("CK_ServerCluster_RedundancyMode_NodeCount", "((NodeCount = 1 AND RedundancyMode = 'None') OR (NodeCount = 2 AND RedundancyMode IN ('Warm', 'Hot')))");
                        });
                });

            modelBuilder.Entity("ZB.MOM.WW.OtOpcUa.Configuration.Entities.Tag", b =>
                {
                    b.Property<Guid>("TagRowId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("uniqueidentifier")
                        .HasDefaultValueSql("NEWSEQUENTIALID()");

                    b.Property<string>("AccessLevel")
                        .IsRequired()
                        .HasMaxLength(16)
                        .HasColumnType("nvarchar(16)");

                    b.Property<string>("DataType")
                        .IsRequired()
                        .HasMaxLength(32)
                        .HasColumnType("nvarchar(32)");

                    b.Property<string>("DeviceId")
                        .IsRequired()
                        .HasMaxLength(64)
                        .HasColumnType("nvarchar(64)");

                    b.Property<string>("Name")
                        .IsRequired()
                        .HasMaxLength(128)
                        .HasColumnType("nvarchar(128)");

                    b.Property<string>("PollGroupId")
                        .HasMaxLength(64)
                        .HasColumnType("nvarchar(64)");

                    b.Property<byte[]>("RowVersion")
                        .IsConcurrencyToken()
                        .IsRequired()
                        .ValueGeneratedOnAddOrUpdate()
                        .HasColumnType("rowversion");

                    b.Property<string>("TagConfig")
                        .IsRequired()
                        .HasColumnType("nvarchar(max)");

                    b.Property<string>("TagGroupId")
                        .HasMaxLength(64)
                        .HasColumnType("nvarchar(64)");

                    b.Property<string>("TagId")
                        .HasMaxLength(64)
                        .HasColumnType("nvarchar(64)");

                    b.Property<bool>("WriteIdempotent")
                        .HasColumnType("bit");

                    b.HasKey("TagRowId");

                    b.HasIndex("TagId")
                        .IsUnique()
                        .HasDatabaseName("UX_Tag_LogicalId")
                        .HasFilter("[TagId] IS NOT NULL");

                    b.HasIndex("DeviceId", "Name")
                        .IsUnique()
                        .HasDatabaseName("UX_Tag_Device_Name")
                        .HasFilter("[TagGroupId] IS NULL");

                    b.HasIndex("DeviceId", "TagGroupId")
                        .HasDatabaseName("IX_Tag_Device");

                    b.HasIndex("DeviceId", "TagGroupId", "Name")
                        .IsUnique()
                        .HasDatabaseName("UX_Tag_Group_Name")
                        .HasFilter("[TagGroupId] IS NOT NULL");

                    b.ToTable("Tag", null, t =>
                        {
                            t.HasCheckConstraint("CK_Tag_TagConfig_IsJson", "ISJSON(TagConfig) = 1");
                        });
                });

            modelBuilder.Entity("ZB.MOM.WW.OtOpcUa.Configuration.Entities.TagGroup", b =>
                {
                    b.Property<Guid>("TagGroupRowId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("uniqueidentifier")
                        .HasDefaultValueSql("NEWSEQUENTIALID()");

                    b.Property<string>("DeviceId")
                        .IsRequired()
                        .HasMaxLength(64)
                        .HasColumnType("nvarchar(64)");

                    b.Property<string>("Name")
                        .IsRequired()
                        .HasMaxLength(128)
                        .HasColumnType("nvarchar(128)");

                    b.Property<string>("ParentTagGroupId")
                        .HasMaxLength(64)
                        .HasColumnType("nvarchar(64)");

                    b.Property<byte[]>("RowVersion")
                        .IsConcurrencyToken()
                        .IsRequired()
                        .ValueGeneratedOnAddOrUpdate()
                        .HasColumnType("rowversion");

                    b.Property<int>("SortOrder")
                        .HasColumnType("int");

                    b.Property<string>("TagGroupId")
                        .HasMaxLength(64)
                        .HasColumnType("nvarchar(64)");

                    b.HasKey("TagGroupRowId");

                    b.HasIndex("DeviceId")
                        .HasDatabaseName("IX_TagGroup_Device");

                    b.HasIndex("TagGroupId")
                        .IsUnique()
                        .HasDatabaseName("UX_TagGroup_LogicalId")
                        .HasFilter("[TagGroupId] IS NOT NULL");

                    b.HasIndex("DeviceId", "Name")
                        .IsUnique()
                        .HasDatabaseName("UX_TagGroup_DeviceRoot_Name")
                        .HasFilter("[ParentTagGroupId] IS NULL");

                    b.HasIndex("DeviceId", "ParentTagGroupId", "Name")
                        .IsUnique()
                        .HasDatabaseName("UX_TagGroup_Parent_Name")
                        .HasFilter("[ParentTagGroupId] IS NOT NULL");

                    b.ToTable("TagGroup", (string)null);
                });

            modelBuilder.Entity("ZB.MOM.WW.OtOpcUa.Configuration.Entities.UnsArea", b =>
                {
                    b.Property<Guid>("UnsAreaRowId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("uniqueidentifier")
                        .HasDefaultValueSql("NEWSEQUENTIALID()");

                    b.Property<string>("ClusterId")
                        .IsRequired()
                        .HasMaxLength(64)
                        .HasColumnType("nvarchar(64)");

                    b.Property<string>("Name")
                        .IsRequired()
                        .HasMaxLength(32)
                        .HasColumnType("nvarchar(32)");

                    b.Property<string>("Notes")
                        .HasMaxLength(512)
                        .HasColumnType("nvarchar(512)");

                    b.Property<byte[]>("RowVersion")
                        .IsConcurrencyToken()
                        .IsRequired()
                        .ValueGeneratedOnAddOrUpdate()
                        .HasColumnType("rowversion");

                    b.Property<string>("UnsAreaId")
                        .HasMaxLength(64)
                        .HasColumnType("nvarchar(64)");

                    b.HasKey("UnsAreaRowId");

                    b.HasIndex("ClusterId")
                        .HasDatabaseName("IX_UnsArea_Cluster");

                    b.HasIndex("UnsAreaId")
                        .IsUnique()
                        .HasDatabaseName("UX_UnsArea_LogicalId")
                        .HasFilter("[UnsAreaId] IS NOT NULL");

                    b.HasIndex("ClusterId", "Name")
                        .IsUnique()
                        .HasDatabaseName("UX_UnsArea_ClusterName");

                    b.ToTable("UnsArea", (string)null);
                });

            modelBuilder.Entity("ZB.MOM.WW.OtOpcUa.Configuration.Entities.UnsLine", b =>
                {
                    b.Property<Guid>("UnsLineRowId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("uniqueidentifier")
                        .HasDefaultValueSql("NEWSEQUENTIALID()");

                    b.Property<string>("Name")
                        .IsRequired()
                        .HasMaxLength(32)
                        .HasColumnType("nvarchar(32)");

                    b.Property<string>("Notes")
                        .HasMaxLength(512)
                        .HasColumnType("nvarchar(512)");

                    b.Property<byte[]>("RowVersion")
                        .IsConcurrencyToken()
                        .IsRequired()
                        .ValueGeneratedOnAddOrUpdate()
                        .HasColumnType("rowversion");

                    b.Property<string>("UnsAreaId")
                        .IsRequired()
                        .HasMaxLength(64)
                        .HasColumnType("nvarchar(64)");

                    b.Property<string>("UnsLineId")
                        .HasMaxLength(64)
                        .HasColumnType("nvarchar(64)");

                    b.HasKey("UnsLineRowId");

                    b.HasIndex("UnsAreaId")
                        .HasDatabaseName("IX_UnsLine_Area");

                    b.HasIndex("UnsLineId")
                        .IsUnique()
                        .HasDatabaseName("UX_UnsLine_LogicalId")
                        .HasFilter("[UnsLineId] IS NOT NULL");

                    b.HasIndex("UnsAreaId", "Name")
                        .IsUnique()
                        .HasDatabaseName("UX_UnsLine_AreaName");

                    b.ToTable("UnsLine", (string)null);
                });

            modelBuilder.Entity("ZB.MOM.WW.OtOpcUa.Configuration.Entities.UnsTagReference", b =>
                {
                    b.Property<Guid>("UnsTagReferenceRowId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("uniqueidentifier")
                        .HasDefaultValueSql("NEWSEQUENTIALID()");

                    b.Property<string>("DisplayNameOverride")
                        .HasMaxLength(128)
                        .HasColumnType("nvarchar(128)");

                    b.Property<string>("EquipmentId")
                        .IsRequired()
                        .HasMaxLength(64)
                        .HasColumnType("nvarchar(64)");

                    b.Property<byte[]>("RowVersion")
                        .IsConcurrencyToken()
                        .IsRequired()
                        .ValueGeneratedOnAddOrUpdate()
                        .HasColumnType("rowversion");

                    b.Property<int>("SortOrder")
                        .HasColumnType("int");

                    b.Property<string>("TagId")
                        .IsRequired()
                        .HasMaxLength(64)
                        .HasColumnType("nvarchar(64)");

                    b.Property<string>("UnsTagReferenceId")
                        .HasMaxLength(64)
                        .HasColumnType("nvarchar(64)");

                    b.HasKey("UnsTagReferenceRowId");

                    b.HasIndex("EquipmentId")
                        .HasDatabaseName("IX_UnsTagReference_Equipment");

                    b.HasIndex("TagId")
                        .HasDatabaseName("IX_UnsTagReference_Tag");

                    b.HasIndex("UnsTagReferenceId")
                        .IsUnique()
                        .HasDatabaseName("UX_UnsTagReference_LogicalId")
                        .HasFilter("[UnsTagReferenceId] IS NOT NULL");

                    b.HasIndex("EquipmentId", "TagId")
                        .IsUnique()
                        .HasDatabaseName("UX_UnsTagReference_Equip_Tag");

                    b.ToTable("UnsTagReference", (string)null);
                });

            modelBuilder.Entity("ZB.MOM.WW.OtOpcUa.Configuration.Entities.VirtualTag", b =>
                {
                    b.Property<Guid>("VirtualTagRowId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("uniqueidentifier")
                        .HasDefaultValueSql("NEWSEQUENTIALID()");

                    b.Property<bool>("ChangeTriggered")
                        .HasColumnType("bit");

                    b.Property<string>("DataType")
                        .IsRequired()
                        .HasMaxLength(32)
                        .HasColumnType("nvarchar(32)");

                    b.Property<bool>("Enabled")
                        .HasColumnType("bit");

                    b.Property<string>("EquipmentId")
                        .IsRequired()
                        .HasMaxLength(64)
                        .HasColumnType("nvarchar(64)");

                    b.Property<bool>("Historize")
                        .HasColumnType("bit");

                    b.Property<string>("Name")
                        .IsRequired()
                        .HasMaxLength(128)
                        .HasColumnType("nvarchar(128)");

                    b.Property<byte[]>("RowVersion")
                        .IsConcurrencyToken()
                        .IsRequired()
                        .ValueGeneratedOnAddOrUpdate()
                        .HasColumnType("rowversion");

                    b.Property<string>("ScriptId")
                        .IsRequired()
                        .HasMaxLength(64)
                        .HasColumnType("nvarchar(64)");

                    b.Property<int?>("TimerIntervalMs")
                        .HasColumnType("int");

                    b.Property<string>("VirtualTagId")
                        .HasMaxLength(64)
                        .HasColumnType("nvarchar(64)");

                    b.HasKey("VirtualTagRowId");

                    b.HasIndex("ScriptId")
                        .HasDatabaseName("IX_VirtualTag_Script");

                    b.HasIndex("VirtualTagId")
                        .IsUnique()
                        .HasDatabaseName("UX_VirtualTag_LogicalId")
                        .HasFilter("[VirtualTagId] IS NOT NULL");

                    b.HasIndex("EquipmentId", "Name")
                        .IsUnique()
                        .HasDatabaseName("UX_VirtualTag_EquipmentPath");

                    b.ToTable("VirtualTag", null, t =>
                        {
                            t.HasCheckConstraint("CK_VirtualTag_TimerInterval_Min", "TimerIntervalMs IS NULL OR TimerIntervalMs >= 50");

                            t.HasCheckConstraint("CK_VirtualTag_Trigger_AtLeastOne", "ChangeTriggered = 1 OR TimerIntervalMs IS NOT NULL");
                        });
                });

            modelBuilder.Entity("ZB.MOM.WW.OtOpcUa.Configuration.Entities.ClusterNode", b =>
                {
                    b.HasOne("ZB.MOM.WW.OtOpcUa.Configuration.Entities.ServerCluster", "Cluster")
                        .WithMany("Nodes")
                        .HasForeignKey("ClusterId")
                        .OnDelete(DeleteBehavior.Restrict)
                        .IsRequired();

                    b.Navigation("Cluster");
                });

            modelBuilder.Entity("ZB.MOM.WW.OtOpcUa.Configuration.Entities.ClusterNodeCredential", b =>
                {
                    b.HasOne("ZB.MOM.WW.OtOpcUa.Configuration.Entities.ClusterNode", "Node")
                        .WithMany("Credentials")
                        .HasForeignKey("NodeId")
                        .OnDelete(DeleteBehavior.Restrict)
                        .IsRequired();

                    b.Navigation("Node");
                });

            modelBuilder.Entity("ZB.MOM.WW.OtOpcUa.Configuration.Entities.DriverInstance", b =>
                {
                    b.HasOne("ZB.MOM.WW.OtOpcUa.Configuration.Entities.ServerCluster", "Cluster")
                        .WithMany()
                        .HasForeignKey("ClusterId")
                        .OnDelete(DeleteBehavior.Restrict)
                        .IsRequired();

                    b.Navigation("Cluster");
                });

            modelBuilder.Entity("ZB.MOM.WW.OtOpcUa.Configuration.Entities.LdapGroupRoleMapping", b =>
                {
                    b.HasOne("ZB.MOM.WW.OtOpcUa.Configuration.Entities.ServerCluster", "Cluster")
                        .WithMany()
                        .HasForeignKey("ClusterId")
                        .OnDelete(DeleteBehavior.Cascade);

                    b.Navigation("Cluster");
                });

            modelBuilder.Entity("ZB.MOM.WW.OtOpcUa.Configuration.Entities.NodeDeploymentState", b =>
                {
                    b.HasOne("ZB.MOM.WW.OtOpcUa.Configuration.Entities.Deployment", "Deployment")
                        .WithMany()
                        .HasForeignKey("DeploymentId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.HasOne("ZB.MOM.WW.OtOpcUa.Configuration.Entities.ClusterNode", "Node")
                        .WithMany()
                        .HasForeignKey("NodeId")
                        .OnDelete(DeleteBehavior.Restrict)
                        .IsRequired();

                    b.Navigation("Deployment");

                    b.Navigation("Node");
                });

            modelBuilder.Entity("ZB.MOM.WW.OtOpcUa.Configuration.Entities.RawFolder", b =>
                {
                    b.HasOne("ZB.MOM.WW.OtOpcUa.Configuration.Entities.ServerCluster", null)
                        .WithMany("RawFolders")
                        .HasForeignKey("ClusterId")
                        .OnDelete(DeleteBehavior.Restrict)
                        .IsRequired();
                });

            modelBuilder.Entity("ZB.MOM.WW.OtOpcUa.Configuration.Entities.UnsArea", b =>
                {
                    b.HasOne("ZB.MOM.WW.OtOpcUa.Configuration.Entities.ServerCluster", "Cluster")
                        .WithMany()
                        .HasForeignKey("ClusterId")
                        .OnDelete(DeleteBehavior.Restrict)
                        .IsRequired();

                    b.Navigation("Cluster");
                });

            modelBuilder.Entity("ZB.MOM.WW.OtOpcUa.Configuration.Entities.ClusterNode", b =>
                {
                    b.Navigation("Credentials");
                });

            modelBuilder.Entity("ZB.MOM.WW.OtOpcUa.Configuration.Entities.ServerCluster", b =>
                {
                    b.Navigation("Nodes");

                    b.Navigation("RawFolders");
                });
#pragma warning restore 612, 618
        }
    }
}
