// <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.Sqlite.Migrations
{
    [DbContext(typeof(ApplicationDbContext))]
    [Migration("20221006071746_remove_online_status")]
    partial class remove_online_status
    {
        protected override void BuildTargetModel(ModelBuilder modelBuilder)
        {
#pragma warning disable 612, 618
            modelBuilder
                .UseCollation("NOCASE")
                .HasAnnotation("ProductVersion", "6.0.9");

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

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

                    b.Property<string>("AlarmDetail")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

                    b.Property<string>("AlarmType")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

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

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

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

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

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

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

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

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

                    b.HasKey("Id");

                    b.HasIndex("CustomerId");

                    b.HasIndex("TenantId");

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

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

                    b.Property<string>("AssetType")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

                    b.Property<string>("Description")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("Name")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

                    b.HasKey("Id");

                    b.HasIndex("CustomerId");

                    b.HasIndex("TenantId");

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

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

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

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

                    b.Property<string>("Description")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

                    b.Property<string>("KeyName")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("Name")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.HasKey("Id");

                    b.HasIndex("AssetId");

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

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

                    b.Property<string>("ActionData")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("ActionName")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("ActionResult")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

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

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

                    b.Property<string>("ObjectName")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

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

                    b.Property<string>("UserId")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("UserName")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.HasKey("Id");

                    b.HasIndex("CustomerId");

                    b.HasIndex("TenantId");

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

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

                    b.Property<string>("AuthToken")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

                    b.Property<string>("Name")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

                    b.HasKey("Id");

                    b.HasIndex("CustomerId");

                    b.HasIndex("TenantId");

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

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

                    b.Property<string>("Dictionary18NKeyName")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("DictionaryColor")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("DictionaryDesc")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

                    b.Property<string>("DictionaryIcon")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("DictionaryName")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("DictionaryPattern")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

                    b.Property<string>("DictionaryTag")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("DictionaryValue")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

                    b.Property<string>("DictionaryValueTypeName")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.HasKey("DictionaryId");

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

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

                    b.Property<string>("DictionaryGroup18NKeyName")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("DictionaryGroupDesc")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("DictionaryGroupKey")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("DictionaryGroupName")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

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

                    b.Property<string>("DictionaryGroupValueTypeName")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.HasKey("DictionaryGroupId");

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

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

                    b.Property<string>("BizData")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("Bizid")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

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

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

                    b.Property<string>("EventDesc")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("EventName")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

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

                    b.Property<string>("MataData")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

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

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

                    b.Property<string>("KeyName")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("ResouceDesc")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

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

                    b.Property<string>("ResourceKey")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("ResourceTag")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

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

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

                    b.Property<string>("ValueBG")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("ValueCS")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("ValueDA")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("ValueDEDE")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("ValueELGR")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("ValueENGR")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("ValueENUS")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("ValueESES")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("ValueFI")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("ValueFRFR")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("ValueHE")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("ValueHRHR")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("ValueHU")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("ValueITIT")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("ValueJAJP")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("ValueKOKR")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("ValueNL")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("ValuePLPL")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("ValuePT")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("ValueSLSL")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("ValueSR")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("ValueSV")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("ValueTRTR")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("ValueUK")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("ValueVI")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("ValueZHCN")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("ValueZHTW")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.HasKey("Id");

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

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

                    b.Property<string>("Address")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("City")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("Country")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("Email")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("Name")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("Phone")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("Province")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("Street")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

                    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("TEXT")
                        .HasColumnOrder(1);

                    b.Property<string>("KeyName")
                        .HasColumnType("TEXT")
                        .HasColumnOrder(2)
                        .UseCollation("NOCASE");

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

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

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

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

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

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

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

                    b.Property<string>("Value_Json")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

                    b.Property<string>("Value_String")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("Value_XML")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

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

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

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

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

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

                    b.Property<string>("Name")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

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

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

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

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

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

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

                    b.Property<string>("DiagramDesc")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("DiagramImage")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("DiagramName")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

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

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

                    b.HasKey("DiagramId");

                    b.HasIndex("CustomerId");

                    b.HasIndex("TenantId");

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

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

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

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

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

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

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

                    b.Property<string>("GraphElementId")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("GraphFill")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

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

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

                    b.Property<string>("GraphShape")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("GraphStroke")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

                    b.Property<string>("GraphTextAnchor")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("GraphTextFill")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("GraphTextFontFamily")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

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

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

                    b.Property<string>("GraphTextVerticalAnchor")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

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

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

                    b.Property<string>("CommondParam")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("CommondType")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

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

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

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

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

                    b.Property<string>("ToolBoxIcon")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("ToolBoxName")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    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")
                        .UseCollation("NOCASE");

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

                    b.Property<string>("ToolBoxType")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.HasKey("ToolBoxId");

                    b.HasIndex("CustomerId");

                    b.HasIndex("TenantId");

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

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

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

                    b.Property<string>("IdentityId")
                        .IsRequired()
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

                    b.Property<string>("IdentityValue")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.HasKey("Id");

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

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

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

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

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

                    b.Property<string>("ModelDesc")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("ModelName")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

                    b.HasKey("DeviceModelId");

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

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

                    b.Property<string>("CommandI18N")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("CommandName")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("CommandParams")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

                    b.Property<string>("CommandTemplate")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("CommandTitle")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

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

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

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

                    b.HasKey("CommandId");

                    b.HasIndex("DeviceModelId");

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

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

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

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

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

                    b.Property<string>("PortDesc")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("PortElementId")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("PortName")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

                    b.Property<string>("PortPic")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

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

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

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

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

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

                    b.Property<string>("SourceElementId")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("SourceId")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("TargeId")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

                    b.Property<string>("TargetElementId")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.HasKey("MappingId");

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

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

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

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

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

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

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

                    b.HasKey("DeviceRuleId");

                    b.HasIndex("DeviceId");

                    b.HasIndex("FlowRuleRuleId");

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

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

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

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

                    b.Property<string>("FieldCode")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

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

                    b.Property<string>("FieldI18nKey")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

                    b.Property<string>("FieldName")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("FieldPattern")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("FieldPocoTypeName")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

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

                    b.Property<string>("FieldUIElementSchema")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("FieldUnit")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("FieldValue")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("FieldValueDataSource")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("FieldValueLocalDataSource")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

                    b.Property<string>("FieldValueTypeName")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

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

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

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

                    b.HasKey("FieldId");

                    b.HasIndex("CustomerId");

                    b.HasIndex("TenantId");

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

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

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

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

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

                    b.Property<string>("FieldCode")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

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

                    b.Property<string>("FieldName")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("FieldUnit")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("FieldValue")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

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

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

                    b.HasKey("FieldValueId");

                    b.HasIndex("CustomerId");

                    b.HasIndex("TenantId");

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

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

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

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

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

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

                    b.Property<string>("FormDesc")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("FormLayout")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("FormName")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("FormSchame")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

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

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

                    b.Property<string>("ModelClass")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

                    b.Property<string>("Url")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.HasKey("FormId");

                    b.HasIndex("CustomerId");

                    b.HasIndex("TenantId");

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

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

                    b.Property<string>("Conditionexpression")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

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

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

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

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

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

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

                    b.Property<string>("FlowType")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("Flowdesc")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("Flowname")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("Incoming")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("NodeProcessClass")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("NodeProcessMethod")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("NodeProcessParams")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("NodeProcessScript")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("NodeProcessScriptType")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("NodeProcessType")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("ObjectId")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("Outgoing")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("SourceId")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("TargetId")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

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

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

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

                    b.Property<string>("bpmnid")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

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

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

                    b.Property<string>("BizId")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("Data")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

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

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

                    b.Property<string>("OperationDesc")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

                    b.Property<string>("Tag")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("bpmnid")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

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

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

                    b.Property<string>("Creator")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

                    b.Property<string>("DefinitionsXml")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("Describes")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("ExecutableCode")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

                    b.Property<string>("Name")
                        .IsRequired()
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

                    b.Property<string>("RuleDesc")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

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

                    b.Property<string>("Runner")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

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

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

                    b.HasKey("RuleId");

                    b.HasIndex("CustomerId");

                    b.HasIndex("TenantId");

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

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

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

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

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

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

                    b.Property<string>("Description")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("GatewayConfiguration")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

                    b.Property<string>("Icon")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("Name")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

                    b.HasKey("Id");

                    b.HasIndex("CustomerId");

                    b.HasIndex("TenantId");

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

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

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

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

                    b.Property<string>("DefaultValue")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

                    b.Property<string>("DisplayName")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("KeyDesc")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("KeyName")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("Place0")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("Place1")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("Place2")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("Place3")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("Place4")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("Place5")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("PlaceOrder0")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("PlaceOrder1")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("PlaceOrder2")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("PlaceOrder3")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("PlaceOrder4")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("PlaceOrder5")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

                    b.Property<string>("Tag")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("Unit")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

                    b.Property<string>("UnitExpression")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.HasKey("Id");

                    b.HasIndex("ProduceId");

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

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

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

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

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

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

                    b.Property<string>("JwtId")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("Token")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("UserId")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.HasKey("Id");

                    b.HasIndex("UserId");

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

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

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

                    b.Property<string>("IdentityUserId")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

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

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

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

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

                    b.Property<string>("DefaultConfig")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("ExecutorDesc")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("ExecutorName")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

                    b.Property<string>("MataData")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("Path")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("Tag")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

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

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

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

                    b.Property<string>("TypeName")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.HasKey("ExecutorId");

                    b.HasIndex("CustomerId");

                    b.HasIndex("TenantId");

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

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

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

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

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

                    b.Property<string>("EventDesc")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("EventName")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("EventNameSpace")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("EventParam")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

                    b.Property<string>("EventTag")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

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

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

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

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

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

                    b.Property<string>("TaskConfig")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.HasKey("BindId");

                    b.HasIndex("RuleTaskExecutorExecutorId");

                    b.HasIndex("SubscriptionEventId");

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

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

                    b.Property<string>("KeyName")
                        .HasColumnType("TEXT")
                        .HasColumnOrder(2)
                        .UseCollation("NOCASE");

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

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

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

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

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

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

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

                    b.Property<string>("Value_Json")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

                    b.Property<string>("Value_String")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("Value_XML")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

                    b.Property<string>("Address")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("City")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("Country")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("EMail")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("Name")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("Phone")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("Province")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("Street")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    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")
                        .UseCollation("NOCASE");

                    b.Property<string>("ConcurrencyStamp")
                        .IsConcurrencyToken()
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("Name")
                        .HasMaxLength(256)
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("NormalizedName")
                        .HasMaxLength(256)
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

                    b.Property<string>("ClaimType")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("ClaimValue")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("RoleId")
                        .IsRequired()
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.HasKey("Id");

                    b.HasIndex("RoleId");

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

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

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

                    b.Property<string>("ConcurrencyStamp")
                        .IsConcurrencyToken()
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("Email")
                        .HasMaxLength(256)
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

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

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

                    b.Property<string>("NormalizedEmail")
                        .HasMaxLength(256)
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("NormalizedUserName")
                        .HasMaxLength(256)
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("PasswordHash")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("PhoneNumber")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

                    b.Property<string>("SecurityStamp")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

                    b.Property<string>("UserName")
                        .HasMaxLength(256)
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

                    b.Property<string>("ClaimType")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("ClaimValue")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("UserId")
                        .IsRequired()
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    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")
                        .UseCollation("NOCASE");

                    b.Property<string>("ProviderKey")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("ProviderDisplayName")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("UserId")
                        .IsRequired()
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    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")
                        .UseCollation("NOCASE");

                    b.Property<string>("RoleId")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    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")
                        .UseCollation("NOCASE");

                    b.Property<string>("LoginProvider")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("Name")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

                    b.Property<string>("Value")
                        .HasColumnType("TEXT")
                        .UseCollation("NOCASE");

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

                    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
        }
    }
}
