// using System; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using ZeroFramework.DeviceCenter.Infrastructure.EntityFrameworks; #nullable disable namespace ZeroFramework.DeviceCenter.Infrastructure.Migrations { [DbContext(typeof(DeviceCenterDbContext))] [Migration("20231205051947_InitialCreate")] partial class InitialCreate { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder .HasAnnotation("ProductVersion", "8.0.0") .HasAnnotation("Relational:MaxIdentifierLength", 128); SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); modelBuilder.HasSequence("EntityFrameworkHiLoSequence") .IncrementsBy(10); modelBuilder.Entity("ZeroFramework.DeviceCenter.Domain.Aggregates.BuyerAggregate.Buyer", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("uniqueidentifier"); b.Property("UserId") .HasColumnType("uniqueidentifier"); b.HasKey("Id"); b.HasIndex("UserId") .IsUnique(); b.ToTable("Buyers", "dbo"); }); modelBuilder.Entity("ZeroFramework.DeviceCenter.Domain.Aggregates.BuyerAggregate.PaymentMethod", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("int"); SqlServerPropertyBuilderExtensions.UseHiLo(b.Property("Id"), "EntityFrameworkHiLoSequence"); b.Property("BuyerId") .HasColumnType("uniqueidentifier"); b.Property("CardNumber") .IsRequired() .HasMaxLength(25) .HasColumnType("nvarchar(25)"); b.Property("CardType") .IsRequired() .HasMaxLength(20) .HasColumnType("nvarchar(20)"); b.Property("Expiration") .HasColumnType("datetimeoffset"); b.HasKey("Id"); b.HasIndex("BuyerId"); b.ToTable("PaymentMethods", "dbo"); }); modelBuilder.Entity("ZeroFramework.DeviceCenter.Domain.Aggregates.DeviceAggregate.Device", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("bigint"); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 100000L); b.Property("Coordinate") .HasMaxLength(30) .HasColumnType("nvarchar(30)"); b.Property("CreationTime") .HasColumnType("datetimeoffset"); b.Property("LastOnlineTime") .HasColumnType("datetimeoffset"); b.Property("Name") .IsRequired() .HasMaxLength(20) .HasColumnType("nvarchar(20)"); b.Property("ProductId") .HasColumnType("int"); b.Property("Remark") .HasMaxLength(100) .HasColumnType("nvarchar(100)"); b.Property("Status") .IsRequired() .HasMaxLength(20) .HasColumnType("nvarchar(20)"); b.Property("TenantId") .HasColumnType("uniqueidentifier"); b.HasKey("Id"); b.ToTable("Devices", "dbo"); }); modelBuilder.Entity("ZeroFramework.DeviceCenter.Domain.Aggregates.DeviceAggregate.DeviceGroup", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("int"); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 100000L); b.Property("CreationTime") .HasColumnType("datetimeoffset"); b.Property("Name") .IsRequired() .HasMaxLength(20) .HasColumnType("nvarchar(20)"); b.Property("ParentId") .HasColumnType("int"); b.Property("Remark") .HasMaxLength(256) .HasColumnType("nvarchar(256)"); b.Property("TenantId") .HasColumnType("uniqueidentifier"); b.HasKey("Id"); b.HasIndex("ParentId"); b.ToTable("DeviceGroups", "dbo"); }); modelBuilder.Entity("ZeroFramework.DeviceCenter.Domain.Aggregates.DeviceAggregate.DeviceGrouping", b => { b.Property("DeviceId") .HasColumnType("bigint"); b.Property("DeviceGroupId") .HasColumnType("int"); b.Property("TenantId") .HasColumnType("uniqueidentifier"); b.HasKey("DeviceId", "DeviceGroupId"); b.HasIndex("DeviceGroupId"); b.ToTable("DeviceGroupings", "dbo"); }); modelBuilder.Entity("ZeroFramework.DeviceCenter.Domain.Aggregates.MonitoringAggregate.MonitoringFactor", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("int"); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); b.Property("ChineseName") .IsRequired() .HasMaxLength(36) .HasColumnType("nvarchar(36)"); b.Property("Decimals") .HasColumnType("int"); b.Property("EnglishName") .IsRequired() .HasMaxLength(36) .HasColumnType("nvarchar(36)"); b.Property("FactorCode") .IsRequired() .HasMaxLength(36) .HasColumnType("nvarchar(36)"); b.Property("Remarks") .HasMaxLength(36) .HasColumnType("nvarchar(36)"); b.Property("Unit") .HasMaxLength(36) .HasColumnType("nvarchar(36)"); b.HasKey("Id"); b.HasIndex("FactorCode") .IsUnique(); b.ToTable("MonitoringFactors", "dbo"); }); modelBuilder.Entity("ZeroFramework.DeviceCenter.Domain.Aggregates.OrderAggregate.Order", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("uniqueidentifier"); b.Property("BuyerId") .HasColumnType("uniqueidentifier"); b.Property("CreationTime") .HasColumnType("datetimeoffset"); b.Property("OrderStatus") .IsRequired() .HasColumnType("nvarchar(max)"); b.Property("PaymentMethodId") .HasColumnType("int"); b.HasKey("Id"); b.HasIndex("BuyerId"); b.HasIndex("PaymentMethodId"); b.ToTable("Orders", "dbo"); }); modelBuilder.Entity("ZeroFramework.DeviceCenter.Domain.Aggregates.OrderAggregate.OrderItem", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("uniqueidentifier"); b.Property("OrderId") .HasColumnType("uniqueidentifier"); b.Property("ProductId") .HasColumnType("int"); b.Property("UnitPrice") .HasPrecision(18, 2) .HasColumnType("decimal(18,2)"); b.Property("Units") .HasColumnType("int"); b.HasKey("Id"); b.HasIndex("OrderId"); b.ToTable("OrderItems", "dbo"); }); modelBuilder.Entity("ZeroFramework.DeviceCenter.Domain.Aggregates.OrderAggregate.OrderStatus", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("int"); SqlServerPropertyBuilderExtensions.UseHiLo(b.Property("Id"), "EntityFrameworkHiLoSequence"); b.Property("Name") .IsRequired() .HasMaxLength(200) .HasColumnType("nvarchar(200)"); b.HasKey("Id"); b.ToTable("OrderStatus", "dbo"); }); modelBuilder.Entity("ZeroFramework.DeviceCenter.Domain.Aggregates.PermissionAggregate.PermissionGrant", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("uniqueidentifier"); b.Property("OperationName") .IsRequired() .HasMaxLength(255) .HasColumnType("nvarchar(255)"); b.Property("ProviderKey") .IsRequired() .HasMaxLength(36) .HasColumnType("nvarchar(36)"); b.Property("ProviderName") .IsRequired() .HasMaxLength(36) .HasColumnType("nvarchar(36)"); b.Property("ResourceGroupId") .HasColumnType("uniqueidentifier"); b.Property("TenantId") .HasColumnType("uniqueidentifier"); b.HasKey("Id"); b.HasIndex("ResourceGroupId"); b.HasIndex("OperationName", "ProviderName", "ProviderKey", "ResourceGroupId", "TenantId") .IsUnique() .HasFilter("[ResourceGroupId] IS NOT NULL AND [TenantId] IS NOT NULL"); b.ToTable("PermissionGrants", "dbo"); }); modelBuilder.Entity("ZeroFramework.DeviceCenter.Domain.Aggregates.ProductAggregate.MeasurementUnit", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("int"); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); b.Property("Remark") .HasMaxLength(100) .HasColumnType("nvarchar(100)"); b.Property("Unit") .IsRequired() .HasMaxLength(20) .HasColumnType("nvarchar(20)"); b.Property("UnitName") .IsRequired() .HasMaxLength(20) .HasColumnType("nvarchar(20)"); b.HasKey("Id"); b.ToTable("MeasurementUnits", "dbo"); }); modelBuilder.Entity("ZeroFramework.DeviceCenter.Domain.Aggregates.ProductAggregate.Product", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("int"); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); b.Property("CreationTime") .HasColumnType("datetimeoffset"); b.Property("DataFormat") .IsRequired() .HasMaxLength(20) .HasColumnType("nvarchar(20)"); b.Property("Features") .HasColumnType("nvarchar(max)"); b.Property("IsDeleted") .HasColumnType("bit"); b.Property("Name") .IsRequired() .HasMaxLength(20) .HasColumnType("nvarchar(20)"); b.Property("NetType") .IsRequired() .HasMaxLength(20) .HasColumnType("nvarchar(20)"); b.Property("NodeType") .IsRequired() .HasMaxLength(20) .HasColumnType("nvarchar(20)"); b.Property("ProtocolType") .IsRequired() .HasMaxLength(20) .HasColumnType("nvarchar(20)"); b.Property("Remark") .HasMaxLength(100) .HasColumnType("nvarchar(100)"); b.Property("TenantId") .HasColumnType("uniqueidentifier"); b.HasKey("Id"); b.ToTable("Products", "dbo"); }); modelBuilder.Entity("ZeroFramework.DeviceCenter.Domain.Aggregates.ProjectAggregate.Project", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("int"); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); b.Property("CreationTime") .HasColumnType("datetimeoffset"); b.Property("Name") .IsRequired() .HasMaxLength(20) .HasColumnType("nvarchar(20)"); b.HasKey("Id"); b.ToTable("Projects", "dbo"); }); modelBuilder.Entity("ZeroFramework.DeviceCenter.Domain.Aggregates.ProjectAggregate.ProjectGroup", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("int"); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); b.Property("CreationTime") .HasColumnType("datetimeoffset"); b.Property("Name") .IsRequired() .HasMaxLength(20) .HasColumnType("nvarchar(20)"); b.Property("ParentId") .HasColumnType("int"); b.Property("ProjectId") .HasColumnType("int"); b.Property("Remark") .HasMaxLength(100) .HasColumnType("nvarchar(100)"); b.Property("Sorting") .HasColumnType("int"); b.HasKey("Id"); b.HasIndex("ParentId"); b.HasIndex("ProjectId"); b.ToTable("ProjectGroups", "dbo"); }); modelBuilder.Entity("ZeroFramework.DeviceCenter.Domain.Aggregates.ResourceGroupAggregate.ResourceGroup", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("uniqueidentifier"); b.Property("DisplayName") .HasMaxLength(256) .HasColumnType("nvarchar(256)"); b.Property("Name") .IsRequired() .HasMaxLength(20) .HasColumnType("nvarchar(20)"); b.Property("TenantId") .HasColumnType("uniqueidentifier"); b.HasKey("Id"); b.HasIndex("Name", "TenantId") .IsUnique() .HasFilter("[TenantId] IS NOT NULL"); b.ToTable("ResourceGroups", "dbo"); }); modelBuilder.Entity("ZeroFramework.DeviceCenter.Domain.Aggregates.ResourceGroupAggregate.ResourceGrouping", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("uniqueidentifier"); b.Property("ResourceGroupId") .HasColumnType("uniqueidentifier"); b.Property("TenantId") .HasColumnType("uniqueidentifier"); b.HasKey("Id"); b.HasIndex("ResourceGroupId"); b.ToTable("ResourceGroupings", "dbo"); }); modelBuilder.Entity("ZeroFramework.DeviceCenter.Infrastructure.Idempotency.ClientRequest", b => { b.Property("Id") .HasColumnType("nvarchar(450)"); b.Property("Name") .IsRequired() .HasColumnType("nvarchar(max)"); b.Property("Time") .HasColumnType("datetimeoffset"); b.HasKey("Id"); b.ToTable("Idempotency", "dbo"); }); modelBuilder.Entity("ZeroFramework.DeviceCenter.Infrastructure.IntegrationEvents.IntegrationEventLog", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("uniqueidentifier"); b.Property("Content") .IsRequired() .HasColumnType("nvarchar(max)"); b.Property("CreationTime") .HasColumnType("datetimeoffset"); b.Property("EventTypeName") .IsRequired() .HasColumnType("nvarchar(max)"); b.Property("Status") .HasColumnType("int"); b.Property("TimesSent") .HasColumnType("int"); b.Property("TransactionId") .HasColumnType("nvarchar(max)"); b.HasKey("Id"); b.ToTable("IntegrationEventLogs", "dbo"); }); modelBuilder.Entity("ZeroFramework.DeviceCenter.Domain.Aggregates.BuyerAggregate.PaymentMethod", b => { b.HasOne("ZeroFramework.DeviceCenter.Domain.Aggregates.BuyerAggregate.Buyer", null) .WithMany("PaymentMethods") .HasForeignKey("BuyerId") .OnDelete(DeleteBehavior.Cascade); }); modelBuilder.Entity("ZeroFramework.DeviceCenter.Domain.Aggregates.DeviceAggregate.DeviceGroup", b => { b.HasOne("ZeroFramework.DeviceCenter.Domain.Aggregates.DeviceAggregate.DeviceGroup", "Parent") .WithMany("Children") .HasForeignKey("ParentId"); b.Navigation("Parent"); }); modelBuilder.Entity("ZeroFramework.DeviceCenter.Domain.Aggregates.DeviceAggregate.DeviceGrouping", b => { b.HasOne("ZeroFramework.DeviceCenter.Domain.Aggregates.DeviceAggregate.DeviceGroup", "DeviceGroup") .WithMany() .HasForeignKey("DeviceGroupId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); b.HasOne("ZeroFramework.DeviceCenter.Domain.Aggregates.DeviceAggregate.Device", "Device") .WithMany() .HasForeignKey("DeviceId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); b.Navigation("Device"); b.Navigation("DeviceGroup"); }); modelBuilder.Entity("ZeroFramework.DeviceCenter.Domain.Aggregates.OrderAggregate.Order", b => { b.HasOne("ZeroFramework.DeviceCenter.Domain.Aggregates.BuyerAggregate.Buyer", null) .WithMany() .HasForeignKey("BuyerId"); b.HasOne("ZeroFramework.DeviceCenter.Domain.Aggregates.BuyerAggregate.PaymentMethod", null) .WithMany() .HasForeignKey("PaymentMethodId") .OnDelete(DeleteBehavior.Restrict); b.OwnsOne("ZeroFramework.DeviceCenter.Domain.Aggregates.OrderAggregate.ShippingAddress", "Address", b1 => { b1.Property("OrderId") .HasColumnType("uniqueidentifier"); b1.Property("City") .IsRequired() .HasColumnType("nvarchar(max)"); b1.Property("Country") .IsRequired() .HasColumnType("nvarchar(max)"); b1.Property("State") .IsRequired() .HasColumnType("nvarchar(max)"); b1.Property("Street") .IsRequired() .HasColumnType("nvarchar(max)"); b1.Property("ZipCode") .IsRequired() .HasColumnType("nvarchar(max)"); b1.HasKey("OrderId"); b1.ToTable("Orders", "dbo"); b1.WithOwner() .HasForeignKey("OrderId"); }); b.Navigation("Address") .IsRequired(); }); modelBuilder.Entity("ZeroFramework.DeviceCenter.Domain.Aggregates.OrderAggregate.OrderItem", b => { b.HasOne("ZeroFramework.DeviceCenter.Domain.Aggregates.OrderAggregate.Order", null) .WithMany("OrderItems") .HasForeignKey("OrderId"); }); modelBuilder.Entity("ZeroFramework.DeviceCenter.Domain.Aggregates.PermissionAggregate.PermissionGrant", b => { b.HasOne("ZeroFramework.DeviceCenter.Domain.Aggregates.ResourceGroupAggregate.ResourceGroup", null) .WithMany() .HasForeignKey("ResourceGroupId"); }); modelBuilder.Entity("ZeroFramework.DeviceCenter.Domain.Aggregates.ProjectAggregate.ProjectGroup", b => { b.HasOne("ZeroFramework.DeviceCenter.Domain.Aggregates.ProjectAggregate.ProjectGroup", "Parent") .WithMany("Children") .HasForeignKey("ParentId"); b.HasOne("ZeroFramework.DeviceCenter.Domain.Aggregates.ProjectAggregate.Project", "Project") .WithMany("Groups") .HasForeignKey("ProjectId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); b.Navigation("Parent"); b.Navigation("Project"); }); modelBuilder.Entity("ZeroFramework.DeviceCenter.Domain.Aggregates.ResourceGroupAggregate.ResourceGrouping", b => { b.HasOne("ZeroFramework.DeviceCenter.Domain.Aggregates.ResourceGroupAggregate.ResourceGroup", null) .WithMany() .HasForeignKey("ResourceGroupId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); b.OwnsOne("ZeroFramework.DeviceCenter.Domain.Aggregates.ResourceGroupAggregate.ResourceDescriptor", "Resource", b1 => { b1.Property("ResourceGroupingId") .HasColumnType("uniqueidentifier"); b1.Property("ResourceId") .IsRequired() .HasMaxLength(255) .HasColumnType("nvarchar(255)") .HasColumnName("ResourceId"); b1.Property("ResourceType") .IsRequired() .HasMaxLength(255) .HasColumnType("nvarchar(255)") .HasColumnName("ResourceType"); b1.HasKey("ResourceGroupingId"); b1.ToTable("ResourceGroupings", "dbo"); b1.WithOwner() .HasForeignKey("ResourceGroupingId"); }); b.Navigation("Resource") .IsRequired(); }); modelBuilder.Entity("ZeroFramework.DeviceCenter.Domain.Aggregates.BuyerAggregate.Buyer", b => { b.Navigation("PaymentMethods"); }); modelBuilder.Entity("ZeroFramework.DeviceCenter.Domain.Aggregates.DeviceAggregate.DeviceGroup", b => { b.Navigation("Children"); }); modelBuilder.Entity("ZeroFramework.DeviceCenter.Domain.Aggregates.OrderAggregate.Order", b => { b.Navigation("OrderItems"); }); modelBuilder.Entity("ZeroFramework.DeviceCenter.Domain.Aggregates.ProjectAggregate.Project", b => { b.Navigation("Groups"); }); modelBuilder.Entity("ZeroFramework.DeviceCenter.Domain.Aggregates.ProjectAggregate.ProjectGroup", b => { b.Navigation("Children"); }); #pragma warning restore 612, 618 } } }