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

#nullable disable

namespace IoTSharp.Data.MySql.Migrations
{
    [DbContext(typeof(ApplicationDbContext))]
    [Migration("20220329045835_AddAssetName")]
    partial class AddAssetName
    {
        protected override void BuildTargetModel(ModelBuilder modelBuilder)
        {
#pragma warning disable 612, 618
            modelBuilder
                .HasAnnotation("ProductVersion", "6.0.3")
                .HasAnnotation("Relational:MaxIdentifierLength", 64);

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

                    b.Property<DateTime>("AckDateTime")
                        .HasColumnType("datetime(6)");

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

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

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

                    b.Property<DateTime>("ClearDateTime")
                        .HasColumnType("datetime(6)");

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

                    b.Property<DateTime>("EndDateTime")
                        .HasColumnType("datetime(6)");

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

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

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

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

                    b.Property<DateTime>("StartDateTime")
                        .HasColumnType("datetime(6)");

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

                    b.HasKey("Id");

                    b.HasIndex("CustomerId");

                    b.HasIndex("TenantId");

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

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

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

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

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

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

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

                    b.HasKey("Id");

                    b.HasIndex("CustomerId");

                    b.HasIndex("TenantId");

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

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

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

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

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

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

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

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

                    b.HasKey("Id");

                    b.HasIndex("AssetId");

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

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

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

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

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

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

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

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

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

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

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

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

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

                    b.HasKey("Id");

                    b.HasIndex("CustomerId");

                    b.HasIndex("TenantId");

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

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

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

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

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

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

                    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");

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

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

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

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

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

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

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

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

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

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

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

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

                    b.HasKey("DictionaryId");

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

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

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

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

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

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

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

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

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

                    b.HasKey("DictionaryGroupId");

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

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

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

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

                    b.Property<DateTime>("CreaterDateTime")
                        .HasColumnType("datetime(6)");

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

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

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

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

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

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

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

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

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

                    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");

                    b.Property<DateTime?>("AddDate")
                        .HasColumnType("datetime(6)");

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    b.HasKey("Id");

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

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

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

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

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

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

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

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

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

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

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

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

                    b.HasKey("Id");

                    b.HasIndex("TenantId");

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    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("char(36)");

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

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

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

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

                    b.Property<DateTime>("LastActive")
                        .HasColumnType("timestamp");

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

                    b.Property<bool>("Online")
                        .HasColumnType("tinyint(1)");

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

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

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

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

                    b.HasKey("Id");

                    b.HasIndex("AuthorizedKeyId");

                    b.HasIndex("CustomerId");

                    b.HasIndex("DeviceModelId");

                    b.HasIndex("OwnerId");

                    b.HasIndex("TenantId");

                    b.ToTable("Device");

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

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

                    b.Property<DateTimeOffset?>("CreateDate")
                        .HasColumnType("datetime(6)");

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

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

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

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

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

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

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

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

                    b.HasKey("DiagramId");

                    b.HasIndex("CustomerId");

                    b.HasIndex("TenantId");

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

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

                    b.Property<DateTime?>("CreateDate")
                        .HasColumnType("datetime(6)");

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    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("char(36)");

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

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

                    b.Property<DateTime?>("CreateDate")
                        .HasColumnType("datetime(6)");

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

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

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

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

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

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

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

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

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

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

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

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

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

                    b.HasKey("ToolBoxId");

                    b.HasIndex("CustomerId");

                    b.HasIndex("TenantId");

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

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

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

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

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

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

                    b.HasKey("Id");

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

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

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

                    b.Property<DateTime>("CreateDateTime")
                        .HasColumnType("datetime(6)");

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

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

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

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

                    b.HasKey("DeviceModelId");

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

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

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

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

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

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

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

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

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

                    b.Property<DateTime>("CreateDateTime")
                        .HasColumnType("datetime(6)");

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

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

                    b.HasKey("CommandId");

                    b.HasIndex("DeviceModelId");

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

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

                    b.Property<DateTime?>("CreateDate")
                        .HasColumnType("datetime(6)");

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

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

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

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

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

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

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

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

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

                    b.HasKey("PortId");

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

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

                    b.Property<DateTime?>("CreateDate")
                        .HasColumnType("datetime(6)");

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

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

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

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

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

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

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

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

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

                    b.HasKey("MappingId");

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

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

                    b.Property<DateTime>("ConfigDateTime")
                        .HasColumnType("datetime(6)");

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

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

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

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

                    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");

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

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

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

                    b.Property<DateTime?>("FieldCreateDate")
                        .HasColumnType("datetime(6)");

                    b.Property<DateTime?>("FieldEditDate")
                        .HasColumnType("datetime(6)");

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    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");

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

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

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

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

                    b.Property<DateTime?>("FieldCreateDate")
                        .HasColumnType("datetime(6)");

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

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

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

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

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

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

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

                    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");

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

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

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

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

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

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

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

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

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

                    b.Property<DateTime?>("FromCreateDate")
                        .HasColumnType("datetime(6)");

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

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

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

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

                    b.HasKey("FormId");

                    b.HasIndex("CustomerId");

                    b.HasIndex("TenantId");

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

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

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

                    b.Property<DateTime>("CreateDate")
                        .HasColumnType("datetime(6)");

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    b.Property<DateTime>("TesterDateTime")
                        .HasColumnType("datetime(6)");

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

                    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("char(36)");

                    b.Property<DateTime?>("AddDate")
                        .HasColumnType("datetime(6)");

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

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

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

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

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

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

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

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

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

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

                    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("char(36)");

                    b.Property<DateTime?>("CreatTime")
                        .HasColumnType("datetime(6)");

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    b.HasKey("RuleId");

                    b.HasIndex("CustomerId");

                    b.HasIndex("TenantId");

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

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

                    b.Property<DateTime>("AddedDate")
                        .HasColumnType("datetime(6)");

                    b.Property<DateTime>("ExpiryDate")
                        .HasColumnType("datetime(6)");

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

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

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

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

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

                    b.HasKey("Id");

                    b.HasIndex("UserId");

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

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

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

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

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

                    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("char(36)");

                    b.Property<DateTime>("AddDateTime")
                        .HasColumnType("datetime(6)");

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

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

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

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

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

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

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

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

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

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

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

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

                    b.Property<DateTime>("TesterDateTime")
                        .HasColumnType("datetime(6)");

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

                    b.HasKey("ExecutorId");

                    b.HasIndex("CustomerId");

                    b.HasIndex("TenantId");

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

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

                    b.Property<DateTime>("CreateDateTime")
                        .HasColumnType("datetime(6)");

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

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

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

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

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

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

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

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

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

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

                    b.HasKey("EventId");

                    b.HasIndex("CustomerId");

                    b.HasIndex("TenantId");

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

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

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

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

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

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

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

                    b.HasKey("BindId");

                    b.HasIndex("RuleTaskExecutorExecutorId");

                    b.HasIndex("SubscriptionEventId");

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    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("char(36)");

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

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

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

                    b.Property<string>("EMail")
                        .HasColumnType("longtext");

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

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

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

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

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

                    b.HasKey("Id");

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

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

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

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

                    b.Property<string>("NormalizedName")
                        .HasMaxLength(256)
                        .HasColumnType("varchar(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("int");

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

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

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

                    b.HasKey("Id");

                    b.HasIndex("RoleId");

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

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

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

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

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

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

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

                    b.Property<DateTimeOffset?>("LockoutEnd")
                        .HasColumnType("datetime(6)");

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

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

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

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

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

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

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

                    b.Property<string>("UserName")
                        .HasMaxLength(256)
                        .HasColumnType("varchar(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("int");

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

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

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

                    b.HasKey("Id");

                    b.HasIndex("UserId");

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

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

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

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

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

                    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("varchar(255)");

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

                    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("varchar(255)");

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

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

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

                    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.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.DeviceModel", "DeviceModel")
                        .WithMany()
                        .HasForeignKey("DeviceModelId");

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

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

                    b.Navigation("Customer");

                    b.Navigation("DeviceModel");

                    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.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.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.Tenant", b =>
                {
                    b.Navigation("Customers");

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

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