// <auto-generated />
using System;
using IoTSharp.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;

#nullable disable

namespace IoTSharp.Migrations
{
    [DbContext(typeof(ApplicationDbContext))]
    [Migration("20221202074042_ModifyEmailSpell")]
    partial class ModifyEmailSpell
    {
        protected override void BuildTargetModel(ModelBuilder modelBuilder)
        {
#pragma warning disable 612, 618
            modelBuilder
                .HasAnnotation("ProductVersion", "6.0.10")
                .HasAnnotation("Relational:MaxIdentifierLength", 63);

            NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);

            modelBuilder.Entity("IoTSharp.Data.Alarm", b =>
                {
                    b.Property<Guid>("Id")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("uuid");

                    b.Property<DateTime>("AckDateTime")
                        .HasColumnType("timestamp with time zone");

                    b.Property<string>("AlarmDetail")
                        .HasColumnType("text");

                    b.Property<int>("AlarmStatus")
                        .HasColumnType("integer");

                    b.Property<string>("AlarmType")
                        .HasColumnType("text");

                    b.Property<DateTime>("ClearDateTime")
                        .HasColumnType("timestamp with time zone");

                    b.Property<Guid?>("CustomerId")
                        .HasColumnType("uuid");

                    b.Property<DateTime>("EndDateTime")
                        .HasColumnType("timestamp with time zone");

                    b.Property<Guid>("OriginatorId")
                        .HasColumnType("uuid");

                    b.Property<int>("OriginatorType")
                        .HasColumnType("integer");

                    b.Property<bool>("Propagate")
                        .HasColumnType("boolean");

                    b.Property<int>("Serverity")
                        .HasColumnType("integer");

                    b.Property<DateTime>("StartDateTime")
                        .HasColumnType("timestamp with time zone");

                    b.Property<Guid?>("TenantId")
                        .HasColumnType("uuid");

                    b.HasKey("Id");

                    b.HasIndex("CustomerId");

                    b.HasIndex("TenantId");

                    b.ToTable("Alarms");
                });

            modelBuilder.Entity("IoTSharp.Data.Asset", b =>
                {
                    b.Property<Guid>("Id")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("uuid");

                    b.Property<string>("AssetType")
                        .HasColumnType("text");

                    b.Property<Guid?>("CustomerId")
                        .HasColumnType("uuid");

                    b.Property<bool>("Deleted")
                        .HasColumnType("boolean");

                    b.Property<string>("Description")
                        .HasColumnType("text");

                    b.Property<string>("Name")
                        .HasColumnType("text");

                    b.Property<Guid?>("TenantId")
                        .HasColumnType("uuid");

                    b.HasKey("Id");

                    b.HasIndex("CustomerId");

                    b.HasIndex("TenantId");

                    b.ToTable("Assets");
                });

            modelBuilder.Entity("IoTSharp.Data.AssetRelation", b =>
                {
                    b.Property<Guid>("Id")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("uuid");

                    b.Property<Guid?>("AssetId")
                        .HasColumnType("uuid");

                    b.Property<int>("DataCatalog")
                        .HasColumnType("integer");

                    b.Property<string>("Description")
                        .HasColumnType("text");

                    b.Property<Guid>("DeviceId")
                        .HasColumnType("uuid");

                    b.Property<string>("KeyName")
                        .HasColumnType("text");

                    b.Property<string>("Name")
                        .HasColumnType("text");

                    b.HasKey("Id");

                    b.HasIndex("AssetId");

                    b.ToTable("AssetRelations");
                });

            modelBuilder.Entity("IoTSharp.Data.AuditLog", b =>
                {
                    b.Property<Guid>("Id")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("uuid");

                    b.Property<string>("ActionData")
                        .HasColumnType("jsonb");

                    b.Property<string>("ActionName")
                        .HasColumnType("text");

                    b.Property<string>("ActionResult")
                        .HasColumnType("jsonb");

                    b.Property<DateTime>("ActiveDateTime")
                        .HasColumnType("timestamp with time zone");

                    b.Property<Guid?>("CustomerId")
                        .HasColumnType("uuid");

                    b.Property<Guid>("ObjectID")
                        .HasColumnType("uuid");

                    b.Property<string>("ObjectName")
                        .HasColumnType("text");

                    b.Property<int>("ObjectType")
                        .HasColumnType("integer");

                    b.Property<Guid?>("TenantId")
                        .HasColumnType("uuid");

                    b.Property<string>("UserId")
                        .HasColumnType("text");

                    b.Property<string>("UserName")
                        .HasColumnType("text");

                    b.HasKey("Id");

                    b.HasIndex("CustomerId");

                    b.HasIndex("TenantId");

                    b.ToTable("AuditLog");
                });

            modelBuilder.Entity("IoTSharp.Data.AuthorizedKey", b =>
                {
                    b.Property<Guid>("Id")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("uuid");

                    b.Property<string>("AuthToken")
                        .HasColumnType("text");

                    b.Property<Guid?>("CustomerId")
                        .HasColumnType("uuid");

                    b.Property<bool>("Deleted")
                        .HasColumnType("boolean");

                    b.Property<string>("Name")
                        .HasColumnType("text");

                    b.Property<Guid?>("TenantId")
                        .HasColumnType("uuid");

                    b.HasKey("Id");

                    b.HasIndex("CustomerId");

                    b.HasIndex("TenantId");

                    b.ToTable("AuthorizedKeys");
                });

            modelBuilder.Entity("IoTSharp.Data.BaseDictionary", b =>
                {
                    b.Property<long>("DictionaryId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("bigint");

                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("DictionaryId"));

                    b.Property<string>("Dictionary18NKeyName")
                        .HasColumnType("text");

                    b.Property<string>("DictionaryColor")
                        .HasColumnType("text");

                    b.Property<string>("DictionaryDesc")
                        .HasColumnType("text");

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

                    b.Property<string>("DictionaryIcon")
                        .HasColumnType("text");

                    b.Property<string>("DictionaryName")
                        .HasColumnType("text");

                    b.Property<string>("DictionaryPattern")
                        .HasColumnType("text");

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

                    b.Property<string>("DictionaryTag")
                        .HasColumnType("text");

                    b.Property<string>("DictionaryValue")
                        .HasColumnType("text");

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

                    b.Property<string>("DictionaryValueTypeName")
                        .HasColumnType("text");

                    b.HasKey("DictionaryId");

                    b.ToTable("BaseDictionaries");
                });

            modelBuilder.Entity("IoTSharp.Data.BaseDictionaryGroup", b =>
                {
                    b.Property<long>("DictionaryGroupId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("bigint");

                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("DictionaryGroupId"));

                    b.Property<string>("DictionaryGroup18NKeyName")
                        .HasColumnType("text");

                    b.Property<string>("DictionaryGroupDesc")
                        .HasColumnType("text");

                    b.Property<string>("DictionaryGroupKey")
                        .HasColumnType("text");

                    b.Property<string>("DictionaryGroupName")
                        .HasColumnType("text");

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

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

                    b.Property<string>("DictionaryGroupValueTypeName")
                        .HasColumnType("text");

                    b.HasKey("DictionaryGroupId");

                    b.ToTable("BaseDictionaryGroups");
                });

            modelBuilder.Entity("IoTSharp.Data.BaseEvent", b =>
                {
                    b.Property<Guid>("EventId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("uuid");

                    b.Property<string>("BizData")
                        .HasColumnType("text");

                    b.Property<string>("Bizid")
                        .HasColumnType("text");

                    b.Property<DateTime>("CreaterDateTime")
                        .HasColumnType("timestamp with time zone");

                    b.Property<Guid>("Creator")
                        .HasColumnType("uuid");

                    b.Property<Guid?>("CustomerId")
                        .HasColumnType("uuid");

                    b.Property<string>("EventDesc")
                        .HasColumnType("text");

                    b.Property<string>("EventName")
                        .HasColumnType("text");

                    b.Property<int>("EventStaus")
                        .HasColumnType("integer");

                    b.Property<Guid?>("FlowRuleRuleId")
                        .HasColumnType("uuid");

                    b.Property<string>("MataData")
                        .HasColumnType("text");

                    b.Property<Guid?>("TenantId")
                        .HasColumnType("uuid");

                    b.Property<int>("Type")
                        .HasColumnType("integer");

                    b.HasKey("EventId");

                    b.HasIndex("CustomerId");

                    b.HasIndex("FlowRuleRuleId");

                    b.HasIndex("TenantId");

                    b.ToTable("BaseEvents");
                });

            modelBuilder.Entity("IoTSharp.Data.BaseI18N", b =>
                {
                    b.Property<long>("Id")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("bigint");

                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));

                    b.Property<DateTime?>("AddDate")
                        .HasColumnType("timestamp with time zone");

                    b.Property<string>("KeyName")
                        .HasColumnType("text");

                    b.Property<string>("ResouceDesc")
                        .HasColumnType("text");

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

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

                    b.Property<string>("ResourceKey")
                        .HasColumnType("text");

                    b.Property<string>("ResourceTag")
                        .HasColumnType("text");

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

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

                    b.Property<Guid>("UserId")
                        .HasColumnType("uuid");

                    b.Property<string>("ValueBG")
                        .HasColumnType("text");

                    b.Property<string>("ValueCS")
                        .HasColumnType("text");

                    b.Property<string>("ValueDA")
                        .HasColumnType("text");

                    b.Property<string>("ValueDEDE")
                        .HasColumnType("text");

                    b.Property<string>("ValueELGR")
                        .HasColumnType("text");

                    b.Property<string>("ValueENGR")
                        .HasColumnType("text");

                    b.Property<string>("ValueENUS")
                        .HasColumnType("text");

                    b.Property<string>("ValueESES")
                        .HasColumnType("text");

                    b.Property<string>("ValueFI")
                        .HasColumnType("text");

                    b.Property<string>("ValueFRFR")
                        .HasColumnType("text");

                    b.Property<string>("ValueHE")
                        .HasColumnType("text");

                    b.Property<string>("ValueHRHR")
                        .HasColumnType("text");

                    b.Property<string>("ValueHU")
                        .HasColumnType("text");

                    b.Property<string>("ValueITIT")
                        .HasColumnType("text");

                    b.Property<string>("ValueJAJP")
                        .HasColumnType("text");

                    b.Property<string>("ValueKOKR")
                        .HasColumnType("text");

                    b.Property<string>("ValueNL")
                        .HasColumnType("text");

                    b.Property<string>("ValuePLPL")
                        .HasColumnType("text");

                    b.Property<string>("ValuePT")
                        .HasColumnType("text");

                    b.Property<string>("ValueSLSL")
                        .HasColumnType("text");

                    b.Property<string>("ValueSR")
                        .HasColumnType("text");

                    b.Property<string>("ValueSV")
                        .HasColumnType("text");

                    b.Property<string>("ValueTRTR")
                        .HasColumnType("text");

                    b.Property<string>("ValueUK")
                        .HasColumnType("text");

                    b.Property<string>("ValueVI")
                        .HasColumnType("text");

                    b.Property<string>("ValueZHCN")
                        .HasColumnType("text");

                    b.Property<string>("ValueZHTW")
                        .HasColumnType("text");

                    b.HasKey("Id");

                    b.ToTable("BaseI18Ns");
                });

            modelBuilder.Entity("IoTSharp.Data.Customer", b =>
                {
                    b.Property<Guid>("Id")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("uuid");

                    b.Property<string>("Address")
                        .HasColumnType("text");

                    b.Property<string>("City")
                        .HasColumnType("text");

                    b.Property<string>("Country")
                        .HasColumnType("text");

                    b.Property<bool>("Deleted")
                        .HasColumnType("boolean");

                    b.Property<string>("Email")
                        .HasColumnType("text");

                    b.Property<string>("Name")
                        .HasColumnType("text");

                    b.Property<string>("Phone")
                        .HasColumnType("text");

                    b.Property<string>("Province")
                        .HasColumnType("text");

                    b.Property<string>("Street")
                        .HasColumnType("text");

                    b.Property<Guid?>("TenantId")
                        .HasColumnType("uuid");

                    b.Property<int>("ZipCode")
                        .HasColumnType("integer");

                    b.HasKey("Id");

                    b.HasIndex("TenantId");

                    b.ToTable("Customer");
                });

            modelBuilder.Entity("IoTSharp.Data.DataStorage", b =>
                {
                    b.Property<int>("Catalog")
                        .HasColumnType("integer")
                        .HasColumnOrder(0);

                    b.Property<Guid>("DeviceId")
                        .HasColumnType("uuid")
                        .HasColumnOrder(1);

                    b.Property<string>("KeyName")
                        .HasColumnType("text")
                        .HasColumnOrder(2);

                    b.Property<int>("DataSide")
                        .HasColumnType("integer")
                        .HasColumnOrder(4);

                    b.Property<DateTime>("DateTime")
                        .HasColumnType("timestamp with time zone")
                        .HasColumnOrder(3);

                    b.Property<int>("Type")
                        .HasColumnType("integer")
                        .HasColumnOrder(5);

                    b.Property<byte[]>("Value_Binary")
                        .HasColumnType("bytea");

                    b.Property<bool?>("Value_Boolean")
                        .HasColumnType("boolean");

                    b.Property<DateTime?>("Value_DateTime")
                        .HasColumnType("timestamp with time zone");

                    b.Property<double?>("Value_Double")
                        .HasColumnType("double precision");

                    b.Property<string>("Value_Json")
                        .HasColumnType("jsonb");

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

                    b.Property<string>("Value_String")
                        .HasColumnType("text");

                    b.Property<string>("Value_XML")
                        .HasColumnType("xml");

                    b.HasKey("Catalog", "DeviceId", "KeyName");

                    b.HasIndex("Catalog");

                    b.HasIndex("Catalog", "DeviceId");

                    b.ToTable("DataStorage");

                    b.HasDiscriminator<int>("Catalog").HasValue(0);
                });

            modelBuilder.Entity("IoTSharp.Data.Device", b =>
                {
                    b.Property<Guid>("Id")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("uuid");

                    b.Property<Guid?>("AuthorizedKeyId")
                        .HasColumnType("uuid");

                    b.Property<Guid?>("CustomerId")
                        .HasColumnType("uuid");

                    b.Property<bool>("Deleted")
                        .HasColumnType("boolean");

                    b.Property<Guid?>("DeviceModelId")
                        .HasColumnType("uuid");

                    b.Property<int>("DeviceType")
                        .HasColumnType("integer");

                    b.Property<string>("Name")
                        .HasColumnType("text");

                    b.Property<Guid?>("OwnerId")
                        .HasColumnType("uuid");

                    b.Property<Guid?>("ProduceId")
                        .HasColumnType("uuid");

                    b.Property<Guid?>("TenantId")
                        .HasColumnType("uuid");

                    b.Property<int>("Timeout")
                        .HasColumnType("integer");

                    b.HasKey("Id");

                    b.HasIndex("AuthorizedKeyId");

                    b.HasIndex("CustomerId");

                    b.HasIndex("OwnerId");

                    b.HasIndex("ProduceId");

                    b.HasIndex("TenantId");

                    b.ToTable("Device");

                    b.HasDiscriminator<int>("DeviceType").HasValue(0);
                });

            modelBuilder.Entity("IoTSharp.Data.DeviceDiagram", b =>
                {
                    b.Property<Guid>("DiagramId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("uuid");

                    b.Property<DateTimeOffset?>("CreateDate")
                        .HasColumnType("timestamp with time zone");

                    b.Property<Guid>("Creator")
                        .HasColumnType("uuid");

                    b.Property<Guid?>("CustomerId")
                        .HasColumnType("uuid");

                    b.Property<string>("DiagramDesc")
                        .HasColumnType("text");

                    b.Property<string>("DiagramImage")
                        .HasColumnType("text");

                    b.Property<string>("DiagramName")
                        .HasColumnType("text");

                    b.Property<int>("DiagramStatus")
                        .HasColumnType("integer");

                    b.Property<bool>("IsDefault")
                        .HasColumnType("boolean");

                    b.Property<Guid?>("TenantId")
                        .HasColumnType("uuid");

                    b.HasKey("DiagramId");

                    b.HasIndex("CustomerId");

                    b.HasIndex("TenantId");

                    b.ToTable("DeviceDiagrams");
                });

            modelBuilder.Entity("IoTSharp.Data.DeviceGraph", b =>
                {
                    b.Property<Guid>("GraphId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("uuid");

                    b.Property<DateTime?>("CreateDate")
                        .HasColumnType("timestamp with time zone");

                    b.Property<Guid>("Creator")
                        .HasColumnType("uuid");

                    b.Property<Guid?>("CustomerId")
                        .HasColumnType("uuid");

                    b.Property<Guid?>("DeviceDiagramDiagramId")
                        .HasColumnType("uuid");

                    b.Property<Guid>("DeviceId")
                        .HasColumnType("uuid");

                    b.Property<string>("GraphElementId")
                        .HasColumnType("text");

                    b.Property<string>("GraphFill")
                        .HasColumnType("text");

                    b.Property<int>("GraphHeight")
                        .HasColumnType("integer");

                    b.Property<int>("GraphPostionX")
                        .HasColumnType("integer");

                    b.Property<int>("GraphPostionY")
                        .HasColumnType("integer");

                    b.Property<string>("GraphShape")
                        .HasColumnType("text");

                    b.Property<string>("GraphStroke")
                        .HasColumnType("text");

                    b.Property<int>("GraphStrokeWidth")
                        .HasColumnType("integer");

                    b.Property<string>("GraphTextAnchor")
                        .HasColumnType("text");

                    b.Property<string>("GraphTextFill")
                        .HasColumnType("text");

                    b.Property<string>("GraphTextFontFamily")
                        .HasColumnType("text");

                    b.Property<int>("GraphTextFontSize")
                        .HasColumnType("integer");

                    b.Property<int>("GraphTextRefX")
                        .HasColumnType("integer");

                    b.Property<int>("GraphTextRefY")
                        .HasColumnType("integer");

                    b.Property<string>("GraphTextVerticalAnchor")
                        .HasColumnType("text");

                    b.Property<int>("GraphWidth")
                        .HasColumnType("integer");

                    b.Property<Guid?>("TenantId")
                        .HasColumnType("uuid");

                    b.HasKey("GraphId");

                    b.HasIndex("CustomerId");

                    b.HasIndex("DeviceDiagramDiagramId");

                    b.HasIndex("TenantId");

                    b.ToTable("DeviceGraphs");
                });

            modelBuilder.Entity("IoTSharp.Data.DeviceGraphToolBox", b =>
                {
                    b.Property<Guid>("ToolBoxId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("uuid");

                    b.Property<string>("CommondParam")
                        .HasColumnType("text");

                    b.Property<string>("CommondType")
                        .HasColumnType("text");

                    b.Property<DateTime?>("CreateDate")
                        .HasColumnType("timestamp with time zone");

                    b.Property<Guid>("Creator")
                        .HasColumnType("uuid");

                    b.Property<Guid?>("CustomerId")
                        .HasColumnType("uuid");

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

                    b.Property<Guid?>("TenantId")
                        .HasColumnType("uuid");

                    b.Property<string>("ToolBoxIcon")
                        .HasColumnType("text");

                    b.Property<string>("ToolBoxName")
                        .HasColumnType("text");

                    b.Property<int>("ToolBoxOffsetLeftPer")
                        .HasColumnType("integer");

                    b.Property<int>("ToolBoxOffsetTopPer")
                        .HasColumnType("integer");

                    b.Property<int>("ToolBoxOffsetX")
                        .HasColumnType("integer");

                    b.Property<int>("ToolBoxOffsetY")
                        .HasColumnType("integer");

                    b.Property<string>("ToolBoxRequestUri")
                        .HasColumnType("text");

                    b.Property<int>("ToolBoxStatus")
                        .HasColumnType("integer");

                    b.Property<string>("ToolBoxType")
                        .HasColumnType("text");

                    b.HasKey("ToolBoxId");

                    b.HasIndex("CustomerId");

                    b.HasIndex("TenantId");

                    b.ToTable("DeviceGraphToolBoxes");
                });

            modelBuilder.Entity("IoTSharp.Data.DeviceIdentity", b =>
                {
                    b.Property<Guid>("Id")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("uuid");

                    b.Property<Guid>("DeviceId")
                        .HasColumnType("uuid");

                    b.Property<string>("IdentityId")
                        .IsRequired()
                        .HasColumnType("text");

                    b.Property<int>("IdentityType")
                        .HasColumnType("integer");

                    b.Property<string>("IdentityValue")
                        .HasColumnType("text");

                    b.HasKey("Id");

                    b.HasIndex("DeviceId")
                        .IsUnique();

                    b.ToTable("DeviceIdentities");
                });

            modelBuilder.Entity("IoTSharp.Data.DeviceModel", b =>
                {
                    b.Property<Guid>("DeviceModelId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("uuid");

                    b.Property<DateTime>("CreateDateTime")
                        .HasColumnType("timestamp with time zone");

                    b.Property<Guid>("Creator")
                        .HasColumnType("uuid");

                    b.Property<string>("ModelDesc")
                        .HasColumnType("text");

                    b.Property<string>("ModelName")
                        .HasColumnType("text");

                    b.Property<int>("ModelStatus")
                        .HasColumnType("integer");

                    b.HasKey("DeviceModelId");

                    b.ToTable("DeviceModels");
                });

            modelBuilder.Entity("IoTSharp.Data.DeviceModelCommand", b =>
                {
                    b.Property<Guid>("CommandId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("uuid");

                    b.Property<string>("CommandI18N")
                        .HasColumnType("text");

                    b.Property<string>("CommandName")
                        .HasColumnType("text");

                    b.Property<string>("CommandParams")
                        .HasColumnType("text");

                    b.Property<int>("CommandStatus")
                        .HasColumnType("integer");

                    b.Property<string>("CommandTemplate")
                        .HasColumnType("text");

                    b.Property<string>("CommandTitle")
                        .HasColumnType("text");

                    b.Property<int>("CommandType")
                        .HasColumnType("integer");

                    b.Property<DateTime>("CreateDateTime")
                        .HasColumnType("timestamp with time zone");

                    b.Property<Guid>("Creator")
                        .HasColumnType("uuid");

                    b.Property<Guid>("DeviceModelId")
                        .HasColumnType("uuid");

                    b.HasKey("CommandId");

                    b.HasIndex("DeviceModelId");

                    b.ToTable("DeviceModelCommands");
                });

            modelBuilder.Entity("IoTSharp.Data.DevicePort", b =>
                {
                    b.Property<Guid>("PortId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("uuid");

                    b.Property<DateTime?>("CreateDate")
                        .HasColumnType("timestamp with time zone");

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

                    b.Property<Guid>("DeviceId")
                        .HasColumnType("uuid");

                    b.Property<string>("PortDesc")
                        .HasColumnType("text");

                    b.Property<string>("PortElementId")
                        .HasColumnType("text");

                    b.Property<string>("PortName")
                        .HasColumnType("text");

                    b.Property<int>("PortPhyType")
                        .HasColumnType("integer");

                    b.Property<string>("PortPic")
                        .HasColumnType("text");

                    b.Property<int>("PortStatus")
                        .HasColumnType("integer");

                    b.Property<int>("PortType")
                        .HasColumnType("integer");

                    b.HasKey("PortId");

                    b.ToTable("DevicePorts");
                });

            modelBuilder.Entity("IoTSharp.Data.DevicePortMapping", b =>
                {
                    b.Property<Guid>("MappingId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("uuid");

                    b.Property<DateTime?>("CreateDate")
                        .HasColumnType("timestamp with time zone");

                    b.Property<Guid>("Creator")
                        .HasColumnType("uuid");

                    b.Property<int>("MappingIndex")
                        .HasColumnType("integer");

                    b.Property<int>("MappingStatus")
                        .HasColumnType("integer");

                    b.Property<Guid>("SourceDeviceId")
                        .HasColumnType("uuid");

                    b.Property<string>("SourceElementId")
                        .HasColumnType("text");

                    b.Property<string>("SourceId")
                        .HasColumnType("text");

                    b.Property<string>("TargeId")
                        .HasColumnType("text");

                    b.Property<Guid>("TargetDeviceId")
                        .HasColumnType("uuid");

                    b.Property<string>("TargetElementId")
                        .HasColumnType("text");

                    b.HasKey("MappingId");

                    b.ToTable("DevicePortMappings");
                });

            modelBuilder.Entity("IoTSharp.Data.DeviceRule", b =>
                {
                    b.Property<Guid>("DeviceRuleId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("uuid");

                    b.Property<DateTime>("ConfigDateTime")
                        .HasColumnType("timestamp with time zone");

                    b.Property<Guid>("ConfigUser")
                        .HasColumnType("uuid");

                    b.Property<Guid?>("DeviceId")
                        .HasColumnType("uuid");

                    b.Property<int>("EnableTrace")
                        .HasColumnType("integer");

                    b.Property<Guid?>("FlowRuleRuleId")
                        .HasColumnType("uuid");

                    b.HasKey("DeviceRuleId");

                    b.HasIndex("DeviceId");

                    b.HasIndex("FlowRuleRuleId");

                    b.ToTable("DeviceRules");
                });

            modelBuilder.Entity("IoTSharp.Data.DynamicFormFieldInfo", b =>
                {
                    b.Property<long>("FieldId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("bigint");

                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("FieldId"));

                    b.Property<Guid>("Creator")
                        .HasColumnType("uuid");

                    b.Property<Guid?>("CustomerId")
                        .HasColumnType("uuid");

                    b.Property<string>("FieldCode")
                        .HasColumnType("text");

                    b.Property<DateTime?>("FieldCreateDate")
                        .HasColumnType("timestamp with time zone");

                    b.Property<DateTime?>("FieldEditDate")
                        .HasColumnType("timestamp with time zone");

                    b.Property<string>("FieldI18nKey")
                        .HasColumnType("text");

                    b.Property<int>("FieldMaxLength")
                        .HasColumnType("integer");

                    b.Property<string>("FieldName")
                        .HasColumnType("text");

                    b.Property<string>("FieldPattern")
                        .HasColumnType("text");

                    b.Property<string>("FieldPocoTypeName")
                        .HasColumnType("text");

                    b.Property<int>("FieldStatus")
                        .HasColumnType("integer");

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

                    b.Property<string>("FieldUIElementSchema")
                        .HasColumnType("text");

                    b.Property<string>("FieldUnit")
                        .HasColumnType("text");

                    b.Property<string>("FieldValue")
                        .HasColumnType("text");

                    b.Property<string>("FieldValueDataSource")
                        .HasColumnType("text");

                    b.Property<string>("FieldValueLocalDataSource")
                        .HasColumnType("text");

                    b.Property<int>("FieldValueType")
                        .HasColumnType("integer");

                    b.Property<string>("FieldValueTypeName")
                        .HasColumnType("text");

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

                    b.Property<bool>("IsEnabled")
                        .HasColumnType("boolean");

                    b.Property<bool>("IsRequired")
                        .HasColumnType("boolean");

                    b.Property<Guid?>("TenantId")
                        .HasColumnType("uuid");

                    b.HasKey("FieldId");

                    b.HasIndex("CustomerId");

                    b.HasIndex("TenantId");

                    b.ToTable("DynamicFormFieldInfos");
                });

            modelBuilder.Entity("IoTSharp.Data.DynamicFormFieldValueInfo", b =>
                {
                    b.Property<long>("FieldValueId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("bigint");

                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("FieldValueId"));

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

                    b.Property<Guid>("Creator")
                        .HasColumnType("uuid");

                    b.Property<Guid?>("CustomerId")
                        .HasColumnType("uuid");

                    b.Property<string>("FieldCode")
                        .HasColumnType("text");

                    b.Property<DateTime?>("FieldCreateDate")
                        .HasColumnType("timestamp with time zone");

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

                    b.Property<string>("FieldName")
                        .HasColumnType("text");

                    b.Property<string>("FieldUnit")
                        .HasColumnType("text");

                    b.Property<string>("FieldValue")
                        .HasColumnType("text");

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

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

                    b.Property<Guid?>("TenantId")
                        .HasColumnType("uuid");

                    b.HasKey("FieldValueId");

                    b.HasIndex("CustomerId");

                    b.HasIndex("TenantId");

                    b.ToTable("DynamicFormFieldValueInfos");
                });

            modelBuilder.Entity("IoTSharp.Data.DynamicFormInfo", b =>
                {
                    b.Property<long>("FormId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("bigint");

                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("FormId"));

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

                    b.Property<Guid>("Creator")
                        .HasColumnType("uuid");

                    b.Property<Guid?>("CustomerId")
                        .HasColumnType("uuid");

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

                    b.Property<string>("FormDesc")
                        .HasColumnType("text");

                    b.Property<string>("FormLayout")
                        .HasColumnType("text");

                    b.Property<string>("FormName")
                        .HasColumnType("text");

                    b.Property<string>("FormSchame")
                        .HasColumnType("text");

                    b.Property<int>("FormStatus")
                        .HasColumnType("integer");

                    b.Property<DateTime?>("FromCreateDate")
                        .HasColumnType("timestamp with time zone");

                    b.Property<bool>("IsCompact")
                        .HasColumnType("boolean");

                    b.Property<string>("ModelClass")
                        .HasColumnType("text");

                    b.Property<Guid?>("TenantId")
                        .HasColumnType("uuid");

                    b.Property<string>("Url")
                        .HasColumnType("text");

                    b.HasKey("FormId");

                    b.HasIndex("CustomerId");

                    b.HasIndex("TenantId");

                    b.ToTable("DynamicFormInfos");
                });

            modelBuilder.Entity("IoTSharp.Data.Flow", b =>
                {
                    b.Property<Guid>("FlowId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("uuid");

                    b.Property<string>("Conditionexpression")
                        .HasColumnType("text");

                    b.Property<DateTime>("CreateDate")
                        .HasColumnType("timestamp with time zone");

                    b.Property<Guid>("CreateId")
                        .HasColumnType("uuid");

                    b.Property<Guid>("Createor")
                        .HasColumnType("uuid");

                    b.Property<Guid?>("CustomerId")
                        .HasColumnType("uuid");

                    b.Property<Guid?>("ExecutorId")
                        .HasColumnType("uuid");

                    b.Property<string>("FlowClass")
                        .HasColumnType("text");

                    b.Property<string>("FlowIcon")
                        .HasColumnType("text");

                    b.Property<string>("FlowNameSpace")
                        .HasColumnType("text");

                    b.Property<Guid?>("FlowRuleRuleId")
                        .HasColumnType("uuid");

                    b.Property<string>("FlowShapeType")
                        .HasColumnType("text");

                    b.Property<int>("FlowStatus")
                        .HasColumnType("integer");

                    b.Property<string>("FlowTag")
                        .HasColumnType("text");

                    b.Property<string>("FlowType")
                        .HasColumnType("text");

                    b.Property<string>("Flowdesc")
                        .HasColumnType("text");

                    b.Property<string>("Flowname")
                        .HasColumnType("text");

                    b.Property<string>("Incoming")
                        .HasColumnType("text");

                    b.Property<string>("Left")
                        .HasColumnType("text");

                    b.Property<string>("NodeProcessClass")
                        .HasColumnType("text");

                    b.Property<string>("NodeProcessMethod")
                        .HasColumnType("text");

                    b.Property<string>("NodeProcessParams")
                        .HasColumnType("text");

                    b.Property<string>("NodeProcessScript")
                        .HasColumnType("text");

                    b.Property<string>("NodeProcessScriptType")
                        .HasColumnType("text");

                    b.Property<string>("NodeProcessType")
                        .HasColumnType("text");

                    b.Property<string>("ObjectId")
                        .HasColumnType("text");

                    b.Property<string>("Outgoing")
                        .HasColumnType("text");

                    b.Property<string>("SourceId")
                        .HasColumnType("text");

                    b.Property<string>("TargetId")
                        .HasColumnType("text");

                    b.Property<Guid?>("TenantId")
                        .HasColumnType("uuid");

                    b.Property<int>("TestStatus")
                        .HasColumnType("integer");

                    b.Property<Guid>("Tester")
                        .HasColumnType("uuid");

                    b.Property<DateTime>("TesterDateTime")
                        .HasColumnType("timestamp with time zone");

                    b.Property<string>("Top")
                        .HasColumnType("text");

                    b.Property<string>("bpmnid")
                        .HasColumnType("text");

                    b.HasKey("FlowId");

                    b.HasIndex("CustomerId");

                    b.HasIndex("ExecutorId");

                    b.HasIndex("FlowRuleRuleId");

                    b.HasIndex("TenantId");

                    b.ToTable("Flows");
                });

            modelBuilder.Entity("IoTSharp.Data.FlowOperation", b =>
                {
                    b.Property<Guid>("OperationId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("uuid");

                    b.Property<DateTime?>("AddDate")
                        .HasColumnType("timestamp with time zone");

                    b.Property<Guid?>("BaseEventEventId")
                        .HasColumnType("uuid");

                    b.Property<string>("BizId")
                        .HasColumnType("text");

                    b.Property<string>("Data")
                        .HasColumnType("text");

                    b.Property<Guid?>("FlowId")
                        .HasColumnType("uuid");

                    b.Property<Guid?>("FlowRuleRuleId")
                        .HasColumnType("uuid");

                    b.Property<int>("NodeStatus")
                        .HasColumnType("integer");

                    b.Property<string>("OperationDesc")
                        .HasColumnType("text");

                    b.Property<int>("Step")
                        .HasColumnType("integer");

                    b.Property<string>("Tag")
                        .HasColumnType("text");

                    b.Property<string>("bpmnid")
                        .HasColumnType("text");

                    b.HasKey("OperationId");

                    b.HasIndex("BaseEventEventId");

                    b.HasIndex("FlowId");

                    b.HasIndex("FlowRuleRuleId");

                    b.ToTable("FlowOperations");
                });

            modelBuilder.Entity("IoTSharp.Data.FlowRule", b =>
                {
                    b.Property<Guid>("RuleId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("uuid");

                    b.Property<DateTime?>("CreatTime")
                        .HasColumnType("timestamp with time zone");

                    b.Property<Guid>("CreateId")
                        .HasColumnType("uuid");

                    b.Property<string>("Creator")
                        .HasColumnType("text");

                    b.Property<Guid?>("CustomerId")
                        .HasColumnType("uuid");

                    b.Property<string>("DefinitionsXml")
                        .HasColumnType("text");

                    b.Property<string>("Describes")
                        .HasColumnType("text");

                    b.Property<string>("ExecutableCode")
                        .HasColumnType("text");

                    b.Property<int>("MountType")
                        .HasColumnType("integer");

                    b.Property<string>("Name")
                        .IsRequired()
                        .HasColumnType("text");

                    b.Property<Guid>("ParentRuleId")
                        .HasColumnType("uuid");

                    b.Property<string>("RuleDesc")
                        .HasColumnType("text");

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

                    b.Property<int>("RuleType")
                        .HasColumnType("integer");

                    b.Property<string>("Runner")
                        .HasColumnType("text");

                    b.Property<double>("SubVersion")
                        .HasColumnType("double precision");

                    b.Property<Guid?>("TenantId")
                        .HasColumnType("uuid");

                    b.Property<double>("Version")
                        .HasColumnType("double precision");

                    b.HasKey("RuleId");

                    b.HasIndex("CustomerId");

                    b.HasIndex("TenantId");

                    b.ToTable("FlowRules");
                });

            modelBuilder.Entity("IoTSharp.Data.Produce", b =>
                {
                    b.Property<Guid>("Id")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("uuid");

                    b.Property<Guid?>("CustomerId")
                        .HasColumnType("uuid");

                    b.Property<int>("DefaultDeviceType")
                        .HasColumnType("integer");

                    b.Property<int>("DefaultIdentityType")
                        .HasColumnType("integer");

                    b.Property<int>("DefaultTimeout")
                        .HasColumnType("integer");

                    b.Property<bool>("Deleted")
                        .HasColumnType("boolean");

                    b.Property<string>("Description")
                        .HasColumnType("text");

                    b.Property<string>("GatewayConfiguration")
                        .HasColumnType("text");

                    b.Property<int>("GatewayType")
                        .HasColumnType("integer");

                    b.Property<string>("Icon")
                        .HasColumnType("text");

                    b.Property<string>("Name")
                        .HasColumnType("text");

                    b.Property<Guid?>("TenantId")
                        .HasColumnType("uuid");

                    b.HasKey("Id");

                    b.HasIndex("CustomerId");

                    b.HasIndex("TenantId");

                    b.ToTable("Produces");
                });

            modelBuilder.Entity("IoTSharp.Data.ProduceDictionary", b =>
                {
                    b.Property<Guid>("Id")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("uuid");

                    b.Property<Guid?>("Customer")
                        .HasColumnType("uuid");

                    b.Property<int>("DataType")
                        .HasColumnType("integer");

                    b.Property<string>("DefaultValue")
                        .HasColumnType("text");

                    b.Property<bool>("Deleted")
                        .HasColumnType("boolean");

                    b.Property<bool>("Display")
                        .HasColumnType("boolean");

                    b.Property<string>("DisplayName")
                        .HasColumnType("text");

                    b.Property<string>("KeyDesc")
                        .HasColumnType("text");

                    b.Property<string>("KeyName")
                        .HasColumnType("text");

                    b.Property<string>("Place0")
                        .HasColumnType("text");

                    b.Property<string>("Place1")
                        .HasColumnType("text");

                    b.Property<string>("Place2")
                        .HasColumnType("text");

                    b.Property<string>("Place3")
                        .HasColumnType("text");

                    b.Property<string>("Place4")
                        .HasColumnType("text");

                    b.Property<string>("Place5")
                        .HasColumnType("text");

                    b.Property<string>("PlaceOrder0")
                        .HasColumnType("text");

                    b.Property<string>("PlaceOrder1")
                        .HasColumnType("text");

                    b.Property<string>("PlaceOrder2")
                        .HasColumnType("text");

                    b.Property<string>("PlaceOrder3")
                        .HasColumnType("text");

                    b.Property<string>("PlaceOrder4")
                        .HasColumnType("text");

                    b.Property<string>("PlaceOrder5")
                        .HasColumnType("text");

                    b.Property<Guid?>("ProduceId")
                        .HasColumnType("uuid");

                    b.Property<string>("Tag")
                        .HasColumnType("text");

                    b.Property<string>("Unit")
                        .HasColumnType("text");

                    b.Property<bool>("UnitConvert")
                        .HasColumnType("boolean");

                    b.Property<string>("UnitExpression")
                        .HasColumnType("text");

                    b.HasKey("Id");

                    b.HasIndex("ProduceId");

                    b.ToTable("ProduceDictionaries");
                });

            modelBuilder.Entity("IoTSharp.Data.RefreshToken", b =>
                {
                    b.Property<Guid>("Id")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("uuid");

                    b.Property<DateTime>("AddedDate")
                        .HasColumnType("timestamp with time zone");

                    b.Property<DateTime>("ExpiryDate")
                        .HasColumnType("timestamp with time zone");

                    b.Property<bool>("IsRevorked")
                        .HasColumnType("boolean");

                    b.Property<bool>("IsUsed")
                        .HasColumnType("boolean");

                    b.Property<string>("JwtId")
                        .HasColumnType("text");

                    b.Property<string>("Token")
                        .HasColumnType("text");

                    b.Property<string>("UserId")
                        .HasColumnType("text");

                    b.HasKey("Id");

                    b.HasIndex("UserId");

                    b.ToTable("RefreshTokens");
                });

            modelBuilder.Entity("IoTSharp.Data.Relationship", b =>
                {
                    b.Property<Guid>("Id")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("uuid");

                    b.Property<Guid?>("CustomerId")
                        .HasColumnType("uuid");

                    b.Property<string>("IdentityUserId")
                        .HasColumnType("text");

                    b.Property<Guid?>("TenantId")
                        .HasColumnType("uuid");

                    b.HasKey("Id");

                    b.HasIndex("CustomerId");

                    b.HasIndex("IdentityUserId");

                    b.HasIndex("TenantId");

                    b.ToTable("Relationship");
                });

            modelBuilder.Entity("IoTSharp.Data.RuleTaskExecutor", b =>
                {
                    b.Property<Guid>("ExecutorId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("uuid");

                    b.Property<DateTime>("AddDateTime")
                        .HasColumnType("timestamp with time zone");

                    b.Property<Guid>("Creator")
                        .HasColumnType("uuid");

                    b.Property<Guid?>("CustomerId")
                        .HasColumnType("uuid");

                    b.Property<string>("DefaultConfig")
                        .HasColumnType("text");

                    b.Property<string>("ExecutorDesc")
                        .HasColumnType("text");

                    b.Property<string>("ExecutorName")
                        .HasColumnType("text");

                    b.Property<int>("ExecutorStatus")
                        .HasColumnType("integer");

                    b.Property<string>("MataData")
                        .HasColumnType("text");

                    b.Property<string>("Path")
                        .HasColumnType("text");

                    b.Property<string>("Tag")
                        .HasColumnType("text");

                    b.Property<Guid?>("TenantId")
                        .HasColumnType("uuid");

                    b.Property<int>("TestStatus")
                        .HasColumnType("integer");

                    b.Property<Guid>("Tester")
                        .HasColumnType("uuid");

                    b.Property<DateTime>("TesterDateTime")
                        .HasColumnType("timestamp with time zone");

                    b.Property<string>("TypeName")
                        .HasColumnType("text");

                    b.HasKey("ExecutorId");

                    b.HasIndex("CustomerId");

                    b.HasIndex("TenantId");

                    b.ToTable("RuleTaskExecutors");
                });

            modelBuilder.Entity("IoTSharp.Data.SubscriptionEvent", b =>
                {
                    b.Property<Guid>("EventId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("uuid");

                    b.Property<DateTime>("CreateDateTime")
                        .HasColumnType("timestamp with time zone");

                    b.Property<Guid>("Creator")
                        .HasColumnType("uuid");

                    b.Property<Guid?>("CustomerId")
                        .HasColumnType("uuid");

                    b.Property<string>("EventDesc")
                        .HasColumnType("text");

                    b.Property<string>("EventName")
                        .HasColumnType("text");

                    b.Property<string>("EventNameSpace")
                        .HasColumnType("text");

                    b.Property<string>("EventParam")
                        .HasColumnType("text");

                    b.Property<int>("EventStatus")
                        .HasColumnType("integer");

                    b.Property<string>("EventTag")
                        .HasColumnType("text");

                    b.Property<Guid?>("TenantId")
                        .HasColumnType("uuid");

                    b.Property<int>("Type")
                        .HasColumnType("integer");

                    b.HasKey("EventId");

                    b.HasIndex("CustomerId");

                    b.HasIndex("TenantId");

                    b.ToTable("SubscriptionEvents");
                });

            modelBuilder.Entity("IoTSharp.Data.SubscriptionTask", b =>
                {
                    b.Property<Guid>("BindId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("uuid");

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

                    b.Property<Guid?>("RuleTaskExecutorExecutorId")
                        .HasColumnType("uuid");

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

                    b.Property<Guid?>("SubscriptionEventId")
                        .HasColumnType("uuid");

                    b.Property<string>("TaskConfig")
                        .HasColumnType("text");

                    b.HasKey("BindId");

                    b.HasIndex("RuleTaskExecutorExecutorId");

                    b.HasIndex("SubscriptionEventId");

                    b.ToTable("SubscriptionTasks");
                });

            modelBuilder.Entity("IoTSharp.Data.TelemetryData", b =>
                {
                    b.Property<Guid>("DeviceId")
                        .HasColumnType("uuid")
                        .HasColumnOrder(1);

                    b.Property<string>("KeyName")
                        .HasColumnType("text")
                        .HasColumnOrder(2);

                    b.Property<DateTime>("DateTime")
                        .HasColumnType("timestamp with time zone")
                        .HasColumnOrder(3);

                    b.Property<int>("DataSide")
                        .HasColumnType("integer")
                        .HasColumnOrder(4);

                    b.Property<int>("Type")
                        .HasColumnType("integer")
                        .HasColumnOrder(5);

                    b.Property<byte[]>("Value_Binary")
                        .HasColumnType("bytea");

                    b.Property<bool?>("Value_Boolean")
                        .HasColumnType("boolean");

                    b.Property<DateTime?>("Value_DateTime")
                        .HasColumnType("timestamp with time zone");

                    b.Property<double?>("Value_Double")
                        .HasColumnType("double precision");

                    b.Property<string>("Value_Json")
                        .HasColumnType("jsonb");

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

                    b.Property<string>("Value_String")
                        .HasColumnType("text");

                    b.Property<string>("Value_XML")
                        .HasColumnType("xml");

                    b.HasKey("DeviceId", "KeyName", "DateTime");

                    b.HasIndex("DeviceId");

                    b.HasIndex("KeyName");

                    b.HasIndex("DeviceId", "KeyName");

                    b.ToTable("TelemetryData");
                });

            modelBuilder.Entity("IoTSharp.Data.Tenant", b =>
                {
                    b.Property<Guid>("Id")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("uuid");

                    b.Property<string>("Address")
                        .HasColumnType("text");

                    b.Property<string>("City")
                        .HasColumnType("text");

                    b.Property<string>("Country")
                        .HasColumnType("text");

                    b.Property<bool>("Deleted")
                        .HasColumnType("boolean");

                    b.Property<string>("Email")
                        .HasColumnType("text");

                    b.Property<string>("Name")
                        .HasColumnType("text");

                    b.Property<string>("Phone")
                        .HasColumnType("text");

                    b.Property<string>("Province")
                        .HasColumnType("text");

                    b.Property<string>("Street")
                        .HasColumnType("text");

                    b.Property<int>("ZipCode")
                        .HasColumnType("integer");

                    b.HasKey("Id");

                    b.ToTable("Tenant");
                });

            modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
                {
                    b.Property<string>("Id")
                        .HasColumnType("text");

                    b.Property<string>("ConcurrencyStamp")
                        .IsConcurrencyToken()
                        .HasColumnType("text");

                    b.Property<string>("Name")
                        .HasMaxLength(256)
                        .HasColumnType("character varying(256)");

                    b.Property<string>("NormalizedName")
                        .HasMaxLength(256)
                        .HasColumnType("character varying(256)");

                    b.HasKey("Id");

                    b.HasIndex("NormalizedName")
                        .IsUnique()
                        .HasDatabaseName("RoleNameIndex");

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

            modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
                {
                    b.Property<int>("Id")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("integer");

                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));

                    b.Property<string>("ClaimType")
                        .HasColumnType("text");

                    b.Property<string>("ClaimValue")
                        .HasColumnType("text");

                    b.Property<string>("RoleId")
                        .IsRequired()
                        .HasColumnType("text");

                    b.HasKey("Id");

                    b.HasIndex("RoleId");

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

            modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b =>
                {
                    b.Property<string>("Id")
                        .HasColumnType("text");

                    b.Property<int>("AccessFailedCount")
                        .HasColumnType("integer");

                    b.Property<string>("ConcurrencyStamp")
                        .IsConcurrencyToken()
                        .HasColumnType("text");

                    b.Property<string>("Email")
                        .HasMaxLength(256)
                        .HasColumnType("character varying(256)");

                    b.Property<bool>("EmailConfirmed")
                        .HasColumnType("boolean");

                    b.Property<bool>("LockoutEnabled")
                        .HasColumnType("boolean");

                    b.Property<DateTimeOffset?>("LockoutEnd")
                        .HasColumnType("timestamp with time zone");

                    b.Property<string>("NormalizedEmail")
                        .HasMaxLength(256)
                        .HasColumnType("character varying(256)");

                    b.Property<string>("NormalizedUserName")
                        .HasMaxLength(256)
                        .HasColumnType("character varying(256)");

                    b.Property<string>("PasswordHash")
                        .HasColumnType("text");

                    b.Property<string>("PhoneNumber")
                        .HasColumnType("text");

                    b.Property<bool>("PhoneNumberConfirmed")
                        .HasColumnType("boolean");

                    b.Property<string>("SecurityStamp")
                        .HasColumnType("text");

                    b.Property<bool>("TwoFactorEnabled")
                        .HasColumnType("boolean");

                    b.Property<string>("UserName")
                        .HasMaxLength(256)
                        .HasColumnType("character varying(256)");

                    b.HasKey("Id");

                    b.HasIndex("NormalizedEmail")
                        .HasDatabaseName("EmailIndex");

                    b.HasIndex("NormalizedUserName")
                        .IsUnique()
                        .HasDatabaseName("UserNameIndex");

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

            modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
                {
                    b.Property<int>("Id")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("integer");

                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));

                    b.Property<string>("ClaimType")
                        .HasColumnType("text");

                    b.Property<string>("ClaimValue")
                        .HasColumnType("text");

                    b.Property<string>("UserId")
                        .IsRequired()
                        .HasColumnType("text");

                    b.HasKey("Id");

                    b.HasIndex("UserId");

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

            modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
                {
                    b.Property<string>("LoginProvider")
                        .HasColumnType("text");

                    b.Property<string>("ProviderKey")
                        .HasColumnType("text");

                    b.Property<string>("ProviderDisplayName")
                        .HasColumnType("text");

                    b.Property<string>("UserId")
                        .IsRequired()
                        .HasColumnType("text");

                    b.HasKey("LoginProvider", "ProviderKey");

                    b.HasIndex("UserId");

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

            modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
                {
                    b.Property<string>("UserId")
                        .HasColumnType("text");

                    b.Property<string>("RoleId")
                        .HasColumnType("text");

                    b.HasKey("UserId", "RoleId");

                    b.HasIndex("RoleId");

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

            modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
                {
                    b.Property<string>("UserId")
                        .HasColumnType("text");

                    b.Property<string>("LoginProvider")
                        .HasColumnType("text");

                    b.Property<string>("Name")
                        .HasColumnType("text");

                    b.Property<string>("Value")
                        .HasColumnType("text");

                    b.HasKey("UserId", "LoginProvider", "Name");

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

            modelBuilder.Entity("IoTSharp.Data.AttributeLatest", b =>
                {
                    b.HasBaseType("IoTSharp.Data.DataStorage");

                    b.HasDiscriminator().HasValue(2);
                });

            modelBuilder.Entity("IoTSharp.Data.Gateway", b =>
                {
                    b.HasBaseType("IoTSharp.Data.Device");

                    b.HasDiscriminator().HasValue(1);
                });

            modelBuilder.Entity("IoTSharp.Data.ProduceData", b =>
                {
                    b.HasBaseType("IoTSharp.Data.DataStorage");

                    b.Property<Guid?>("OwnerId")
                        .HasColumnType("uuid");

                    b.HasIndex("OwnerId");

                    b.HasDiscriminator().HasValue(5);
                });

            modelBuilder.Entity("IoTSharp.Data.TelemetryLatest", b =>
                {
                    b.HasBaseType("IoTSharp.Data.DataStorage");

                    b.HasDiscriminator().HasValue(4);
                });

            modelBuilder.Entity("IoTSharp.Data.Alarm", b =>
                {
                    b.HasOne("IoTSharp.Data.Customer", "Customer")
                        .WithMany()
                        .HasForeignKey("CustomerId");

                    b.HasOne("IoTSharp.Data.Tenant", "Tenant")
                        .WithMany()
                        .HasForeignKey("TenantId");

                    b.Navigation("Customer");

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

            modelBuilder.Entity("IoTSharp.Data.Asset", b =>
                {
                    b.HasOne("IoTSharp.Data.Customer", "Customer")
                        .WithMany()
                        .HasForeignKey("CustomerId");

                    b.HasOne("IoTSharp.Data.Tenant", "Tenant")
                        .WithMany()
                        .HasForeignKey("TenantId");

                    b.Navigation("Customer");

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

            modelBuilder.Entity("IoTSharp.Data.AssetRelation", b =>
                {
                    b.HasOne("IoTSharp.Data.Asset", null)
                        .WithMany("OwnedAssets")
                        .HasForeignKey("AssetId");
                });

            modelBuilder.Entity("IoTSharp.Data.AuditLog", b =>
                {
                    b.HasOne("IoTSharp.Data.Customer", "Customer")
                        .WithMany()
                        .HasForeignKey("CustomerId");

                    b.HasOne("IoTSharp.Data.Tenant", "Tenant")
                        .WithMany()
                        .HasForeignKey("TenantId");

                    b.Navigation("Customer");

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

            modelBuilder.Entity("IoTSharp.Data.AuthorizedKey", b =>
                {
                    b.HasOne("IoTSharp.Data.Customer", "Customer")
                        .WithMany()
                        .HasForeignKey("CustomerId");

                    b.HasOne("IoTSharp.Data.Tenant", "Tenant")
                        .WithMany()
                        .HasForeignKey("TenantId");

                    b.Navigation("Customer");

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

            modelBuilder.Entity("IoTSharp.Data.BaseEvent", b =>
                {
                    b.HasOne("IoTSharp.Data.Customer", "Customer")
                        .WithMany()
                        .HasForeignKey("CustomerId");

                    b.HasOne("IoTSharp.Data.FlowRule", "FlowRule")
                        .WithMany()
                        .HasForeignKey("FlowRuleRuleId");

                    b.HasOne("IoTSharp.Data.Tenant", "Tenant")
                        .WithMany()
                        .HasForeignKey("TenantId");

                    b.Navigation("Customer");

                    b.Navigation("FlowRule");

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

            modelBuilder.Entity("IoTSharp.Data.Customer", b =>
                {
                    b.HasOne("IoTSharp.Data.Tenant", "Tenant")
                        .WithMany("Customers")
                        .HasForeignKey("TenantId");

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

            modelBuilder.Entity("IoTSharp.Data.Device", b =>
                {
                    b.HasOne("IoTSharp.Data.AuthorizedKey", null)
                        .WithMany("Devices")
                        .HasForeignKey("AuthorizedKeyId");

                    b.HasOne("IoTSharp.Data.Customer", "Customer")
                        .WithMany("Devices")
                        .HasForeignKey("CustomerId");

                    b.HasOne("IoTSharp.Data.Gateway", "Owner")
                        .WithMany("Children")
                        .HasForeignKey("OwnerId");

                    b.HasOne("IoTSharp.Data.Produce", null)
                        .WithMany("Devices")
                        .HasForeignKey("ProduceId");

                    b.HasOne("IoTSharp.Data.Tenant", "Tenant")
                        .WithMany("Devices")
                        .HasForeignKey("TenantId");

                    b.Navigation("Customer");

                    b.Navigation("Owner");

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

            modelBuilder.Entity("IoTSharp.Data.DeviceDiagram", b =>
                {
                    b.HasOne("IoTSharp.Data.Customer", "Customer")
                        .WithMany()
                        .HasForeignKey("CustomerId");

                    b.HasOne("IoTSharp.Data.Tenant", "Tenant")
                        .WithMany()
                        .HasForeignKey("TenantId");

                    b.Navigation("Customer");

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

            modelBuilder.Entity("IoTSharp.Data.DeviceGraph", b =>
                {
                    b.HasOne("IoTSharp.Data.Customer", "Customer")
                        .WithMany()
                        .HasForeignKey("CustomerId");

                    b.HasOne("IoTSharp.Data.DeviceDiagram", "DeviceDiagram")
                        .WithMany()
                        .HasForeignKey("DeviceDiagramDiagramId");

                    b.HasOne("IoTSharp.Data.Tenant", "Tenant")
                        .WithMany()
                        .HasForeignKey("TenantId");

                    b.Navigation("Customer");

                    b.Navigation("DeviceDiagram");

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

            modelBuilder.Entity("IoTSharp.Data.DeviceGraphToolBox", b =>
                {
                    b.HasOne("IoTSharp.Data.Customer", "Customer")
                        .WithMany()
                        .HasForeignKey("CustomerId");

                    b.HasOne("IoTSharp.Data.Tenant", "Tenant")
                        .WithMany()
                        .HasForeignKey("TenantId");

                    b.Navigation("Customer");

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

            modelBuilder.Entity("IoTSharp.Data.DeviceIdentity", b =>
                {
                    b.HasOne("IoTSharp.Data.Device", "Device")
                        .WithOne("DeviceIdentity")
                        .HasForeignKey("IoTSharp.Data.DeviceIdentity", "DeviceId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

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

            modelBuilder.Entity("IoTSharp.Data.DeviceModelCommand", b =>
                {
                    b.HasOne("IoTSharp.Data.DeviceModel", "DeviceModel")
                        .WithMany("DeviceModelCommands")
                        .HasForeignKey("DeviceModelId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

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

            modelBuilder.Entity("IoTSharp.Data.DeviceRule", b =>
                {
                    b.HasOne("IoTSharp.Data.Device", "Device")
                        .WithMany()
                        .HasForeignKey("DeviceId");

                    b.HasOne("IoTSharp.Data.FlowRule", "FlowRule")
                        .WithMany()
                        .HasForeignKey("FlowRuleRuleId");

                    b.Navigation("Device");

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

            modelBuilder.Entity("IoTSharp.Data.DynamicFormFieldInfo", b =>
                {
                    b.HasOne("IoTSharp.Data.Customer", "Customer")
                        .WithMany()
                        .HasForeignKey("CustomerId");

                    b.HasOne("IoTSharp.Data.Tenant", "Tenant")
                        .WithMany()
                        .HasForeignKey("TenantId");

                    b.Navigation("Customer");

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

            modelBuilder.Entity("IoTSharp.Data.DynamicFormFieldValueInfo", b =>
                {
                    b.HasOne("IoTSharp.Data.Customer", "Customer")
                        .WithMany()
                        .HasForeignKey("CustomerId");

                    b.HasOne("IoTSharp.Data.Tenant", "Tenant")
                        .WithMany()
                        .HasForeignKey("TenantId");

                    b.Navigation("Customer");

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

            modelBuilder.Entity("IoTSharp.Data.DynamicFormInfo", b =>
                {
                    b.HasOne("IoTSharp.Data.Customer", "Customer")
                        .WithMany()
                        .HasForeignKey("CustomerId");

                    b.HasOne("IoTSharp.Data.Tenant", "Tenant")
                        .WithMany()
                        .HasForeignKey("TenantId");

                    b.Navigation("Customer");

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

            modelBuilder.Entity("IoTSharp.Data.Flow", b =>
                {
                    b.HasOne("IoTSharp.Data.Customer", "Customer")
                        .WithMany()
                        .HasForeignKey("CustomerId");

                    b.HasOne("IoTSharp.Data.RuleTaskExecutor", "Executor")
                        .WithMany()
                        .HasForeignKey("ExecutorId");

                    b.HasOne("IoTSharp.Data.FlowRule", "FlowRule")
                        .WithMany()
                        .HasForeignKey("FlowRuleRuleId");

                    b.HasOne("IoTSharp.Data.Tenant", "Tenant")
                        .WithMany()
                        .HasForeignKey("TenantId");

                    b.Navigation("Customer");

                    b.Navigation("Executor");

                    b.Navigation("FlowRule");

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

            modelBuilder.Entity("IoTSharp.Data.FlowOperation", b =>
                {
                    b.HasOne("IoTSharp.Data.BaseEvent", "BaseEvent")
                        .WithMany()
                        .HasForeignKey("BaseEventEventId");

                    b.HasOne("IoTSharp.Data.Flow", "Flow")
                        .WithMany()
                        .HasForeignKey("FlowId");

                    b.HasOne("IoTSharp.Data.FlowRule", "FlowRule")
                        .WithMany()
                        .HasForeignKey("FlowRuleRuleId");

                    b.Navigation("BaseEvent");

                    b.Navigation("Flow");

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

            modelBuilder.Entity("IoTSharp.Data.FlowRule", b =>
                {
                    b.HasOne("IoTSharp.Data.Customer", "Customer")
                        .WithMany()
                        .HasForeignKey("CustomerId");

                    b.HasOne("IoTSharp.Data.Tenant", "Tenant")
                        .WithMany()
                        .HasForeignKey("TenantId");

                    b.Navigation("Customer");

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

            modelBuilder.Entity("IoTSharp.Data.Produce", b =>
                {
                    b.HasOne("IoTSharp.Data.Customer", "Customer")
                        .WithMany()
                        .HasForeignKey("CustomerId");

                    b.HasOne("IoTSharp.Data.Tenant", "Tenant")
                        .WithMany()
                        .HasForeignKey("TenantId");

                    b.Navigation("Customer");

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

            modelBuilder.Entity("IoTSharp.Data.ProduceDictionary", b =>
                {
                    b.HasOne("IoTSharp.Data.Produce", null)
                        .WithMany("Dictionaries")
                        .HasForeignKey("ProduceId");
                });

            modelBuilder.Entity("IoTSharp.Data.RefreshToken", b =>
                {
                    b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", "User")
                        .WithMany()
                        .HasForeignKey("UserId");

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

            modelBuilder.Entity("IoTSharp.Data.Relationship", b =>
                {
                    b.HasOne("IoTSharp.Data.Customer", "Customer")
                        .WithMany()
                        .HasForeignKey("CustomerId");

                    b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", "IdentityUser")
                        .WithMany()
                        .HasForeignKey("IdentityUserId");

                    b.HasOne("IoTSharp.Data.Tenant", "Tenant")
                        .WithMany()
                        .HasForeignKey("TenantId");

                    b.Navigation("Customer");

                    b.Navigation("IdentityUser");

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

            modelBuilder.Entity("IoTSharp.Data.RuleTaskExecutor", b =>
                {
                    b.HasOne("IoTSharp.Data.Customer", "Customer")
                        .WithMany()
                        .HasForeignKey("CustomerId");

                    b.HasOne("IoTSharp.Data.Tenant", "Tenant")
                        .WithMany()
                        .HasForeignKey("TenantId");

                    b.Navigation("Customer");

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

            modelBuilder.Entity("IoTSharp.Data.SubscriptionEvent", b =>
                {
                    b.HasOne("IoTSharp.Data.Customer", "Customer")
                        .WithMany()
                        .HasForeignKey("CustomerId");

                    b.HasOne("IoTSharp.Data.Tenant", "Tenant")
                        .WithMany()
                        .HasForeignKey("TenantId");

                    b.Navigation("Customer");

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

            modelBuilder.Entity("IoTSharp.Data.SubscriptionTask", b =>
                {
                    b.HasOne("IoTSharp.Data.RuleTaskExecutor", "RuleTaskExecutor")
                        .WithMany()
                        .HasForeignKey("RuleTaskExecutorExecutorId");

                    b.HasOne("IoTSharp.Data.SubscriptionEvent", "Subscription")
                        .WithMany()
                        .HasForeignKey("SubscriptionEventId");

                    b.Navigation("RuleTaskExecutor");

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

            modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
                {
                    b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
                        .WithMany()
                        .HasForeignKey("RoleId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();
                });

            modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
                {
                    b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
                        .WithMany()
                        .HasForeignKey("UserId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();
                });

            modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
                {
                    b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
                        .WithMany()
                        .HasForeignKey("UserId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();
                });

            modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
                {
                    b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
                        .WithMany()
                        .HasForeignKey("RoleId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
                        .WithMany()
                        .HasForeignKey("UserId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();
                });

            modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
                {
                    b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
                        .WithMany()
                        .HasForeignKey("UserId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();
                });

            modelBuilder.Entity("IoTSharp.Data.ProduceData", b =>
                {
                    b.HasOne("IoTSharp.Data.Produce", "Owner")
                        .WithMany("DefaultAttributes")
                        .HasForeignKey("OwnerId");

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

            modelBuilder.Entity("IoTSharp.Data.Asset", b =>
                {
                    b.Navigation("OwnedAssets");
                });

            modelBuilder.Entity("IoTSharp.Data.AuthorizedKey", b =>
                {
                    b.Navigation("Devices");
                });

            modelBuilder.Entity("IoTSharp.Data.Customer", b =>
                {
                    b.Navigation("Devices");
                });

            modelBuilder.Entity("IoTSharp.Data.Device", b =>
                {
                    b.Navigation("DeviceIdentity");
                });

            modelBuilder.Entity("IoTSharp.Data.DeviceModel", b =>
                {
                    b.Navigation("DeviceModelCommands");
                });

            modelBuilder.Entity("IoTSharp.Data.Produce", b =>
                {
                    b.Navigation("DefaultAttributes");

                    b.Navigation("Devices");

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

            modelBuilder.Entity("IoTSharp.Data.Tenant", b =>
                {
                    b.Navigation("Customers");

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

            modelBuilder.Entity("IoTSharp.Data.Gateway", b =>
                {
                    b.Navigation("Children");
                });
#pragma warning restore 612, 618
        }
    }
}
