提交 6a868571 编写于 作者: 麦壳饼's avatar 麦壳饼

Add Data Tables , Add Discriminator

上级 03f80165
......@@ -30,23 +30,37 @@ namespace IoTSharp.Hub.Data
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
//switch (DatabaseType)
//{
// case DatabaseType.mssql:
// ForSqlServer(modelBuilder);
// break;
// case DatabaseType.npgsql:
// ForNpgsql(modelBuilder);
// break;
// case DatabaseType.sqlite:
// break;
// default:
// break;
//}
modelBuilder.Entity<DataStorage>()
.HasDiscriminator<DataCatalog>(nameof(Data.DataStorage.Catalog))
.HasValue<DataStorage>(DataCatalog.None)
.HasValue<AttributeData>(DataCatalog.AttributeData)
.HasValue<AttributeLatest>(DataCatalog.AttributeLatest)
.HasValue<TelemetryData>(DataCatalog.TelemetryData)
.HasValue<TelemetryLatest>(DataCatalog.TelemetryLatest);
modelBuilder.Entity<AttributeData>().HasDiscriminator<DataCatalog>(nameof(Data.DataStorage.Catalog));
modelBuilder.Entity<AttributeLatest>().HasDiscriminator<DataCatalog>(nameof(Data.DataStorage.Catalog));
modelBuilder.Entity<TelemetryData>().HasDiscriminator<DataCatalog>(nameof(Data.DataStorage.Catalog));
modelBuilder.Entity<TelemetryLatest>().HasDiscriminator<DataCatalog>(nameof(Data.DataStorage.Catalog));
switch (DatabaseType)
{
case DatabaseType.mssql:
ForSqlServer(modelBuilder);
break;
case DatabaseType.npgsql:
ForNpgsql(modelBuilder);
break;
case DatabaseType.sqlite:
break;
default:
break;
}
}
private void ForNpgsql(ModelBuilder modelBuilder)
......@@ -67,11 +81,11 @@ namespace IoTSharp.Hub.Data
.Property(b => b.Value_XML)
.HasColumnType("xml");
modelBuilder.Entity<AttributeData>()
modelBuilder.Entity<DataStorage>()
.Property(b => b.Value_Json)
.HasColumnType("jsonb");
modelBuilder.Entity<AttributeData>()
modelBuilder.Entity<DataStorage>()
.Property(b => b.Value_XML)
.HasColumnType("xml");
......@@ -94,7 +108,7 @@ namespace IoTSharp.Hub.Data
.Property(b => b.Value_XML)
.HasColumnType("xml");
modelBuilder.Entity<AttributeData>()
modelBuilder.Entity<DataStorage>()
.Property(b => b.Value_XML)
.HasColumnType("xml");
......@@ -103,16 +117,17 @@ namespace IoTSharp.Hub.Data
.HasColumnType("xml");
}
//public DbSet<Tenant> Tenant { get; set; }
//public DbSet<Customer> Customer { get; set; }
//public DbSet<Relationship> Relationship { get; set; }
//public DbSet<Device> Device { get; set; }
public DbSet<Tenant> Tenant { get; set; }
public DbSet<Customer> Customer { get; set; }
//public DbSet<TelemetryData> TelemetryData { get; set; }
//public DbSet<AttributeLatest> AttributeLatest { get; set; }
//public DbSet<AttributeData> AttributeData { get; set; }
public DbSet<Relationship> Relationship { get; set; }
public DbSet<Device> Device { get; set; }
//public DbSet<TelemetryLatest> TelemetryLatest { get; set; }
public DbSet<TelemetryData> TelemetryData { get; set; }
public DbSet<AttributeLatest> AttributeLatest { get; set; }
public DbSet<DataStorage> DataStorage { get; set; }
public DbSet<AttributeData> AttributeData { get; set; }
public DbSet<TelemetryLatest> TelemetryLatest { get; set; }
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;
namespace IoTSharp.Hub.Data
{
public class AttributeData
public class AttributeData : DataStorage
{
[Key]
public Guid Id { get; set; }
[Required]
public string KeyName { get; set; }
[Required]
[EnumDataType(typeof(DataType))]
public DataType Type { get; set; }
public DateTime DateTime { get; set; }
public bool Value_Boolean { get; set; }
public string Value_String { get; set; }
public long Value_Long { get; set; }
public double Value_Double { get; set; }
public string Value_Json { get; set; }
public string Value_XML { get; set; }
public byte[] Value_Binary { get; set; }
}
}
......@@ -6,10 +6,8 @@ using System.Threading.Tasks;
namespace IoTSharp.Hub.Data
{
public class AttributeLatest : AttributeData
public class AttributeLatest : DataStorage
{
[Required]
[EnumDataType(typeof(KeyValueScope))]
public KeyValueScope Scope { get; set; }
}
}
using System;
using System.ComponentModel.DataAnnotations;
namespace IoTSharp.Hub.Data
{
public class DataStorage
{
[Key]
public Guid Id { get; set; }
[Required]
public string KeyName { get; set; }
[Required]
public Device Device { get; set; }
[Required]
[EnumDataType(typeof(DataCatalog))]
public DataCatalog Catalog { get; set; }
[Required]
[EnumDataType(typeof(DataType))]
public DataType Type { get; set; }
public DateTime DateTime { get; set; }
public bool Value_Boolean { get; set; }
public string Value_String { get; set; }
public long Value_Long { get; set; }
public double Value_Double { get; set; }
public string Value_Json { get; set; }
public string Value_XML { get; set; }
public byte[] Value_Binary { get; set; }
}
}
......@@ -17,7 +17,7 @@ namespace IoTSharp.Hub.Data
public Customer Customer { get; set; }
public virtual List<AttributeData> AttributeData { get; set; }
public virtual List<DataStorage> AttributeData { get; set; }
public virtual List<AttributeLatest> AttributeLatest { get; set; }
public virtual List<TelemetryData> TelemetryData { get; set; }
......
......@@ -6,11 +6,14 @@ using System.Threading.Tasks;
namespace IoTSharp.Hub.Data
{
public enum KeyValueScope
public enum DataCatalog
{
ShareSide,
ServerSide,
ClientSide
None,
AttributeData,
AttributeLatest,
TelemetryData,
TelemetryLatest,
}
public enum DataType
......
// <auto-generated />
using System;
using IoTSharp.Hub.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace IoTSharp.Hub.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20190103085249_AddDataTable")]
partial class AddDataTable
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn)
.HasAnnotation("ProductVersion", "2.2.0-rtm-35687")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
modelBuilder.Entity("IoTSharp.Hub.Data.AttributeData", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd();
b.Property<DateTime>("DateTime");
b.Property<Guid>("DeviceId1");
b.Property<string>("Discriminator")
.IsRequired();
b.Property<string>("KeyName")
.IsRequired();
b.Property<int>("Type");
b.Property<byte[]>("Value_Binary");
b.Property<bool>("Value_Boolean");
b.Property<double>("Value_Double");
b.Property<string>("Value_Json")
.HasColumnType("jsonb");
b.Property<long>("Value_Long");
b.Property<string>("Value_String");
b.Property<string>("Value_XML")
.HasColumnType("xml");
b.HasKey("Id");
b.HasIndex("DeviceId1");
b.ToTable("AttributeData");
b.HasDiscriminator<string>("Discriminator").HasValue("AttributeData");
});
modelBuilder.Entity("IoTSharp.Hub.Data.Customer", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("Address");
b.Property<string>("City");
b.Property<string>("Country");
b.Property<string>("Email");
b.Property<string>("Name");
b.Property<string>("Phone");
b.Property<string>("Province");
b.Property<string>("Street");
b.Property<Guid?>("TenantId");
b.Property<int>("ZipCode");
b.HasKey("Id");
b.HasIndex("TenantId");
b.ToTable("Customer");
});
modelBuilder.Entity("IoTSharp.Hub.Data.Device", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd();
b.Property<Guid?>("CustomerId");
b.Property<string>("Name");
b.Property<Guid?>("TenantId");
b.Property<string>("Type");
b.HasKey("Id");
b.HasIndex("CustomerId");
b.HasIndex("TenantId");
b.ToTable("Device");
});
modelBuilder.Entity("IoTSharp.Hub.Data.Relationship", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd();
b.Property<Guid?>("CustomerId");
b.Property<string>("IdentityId");
b.Property<Guid?>("TenantId");
b.HasKey("Id");
b.HasIndex("CustomerId");
b.HasIndex("IdentityId");
b.HasIndex("TenantId");
b.ToTable("Relationship");
});
modelBuilder.Entity("IoTSharp.Hub.Data.Tenant", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("Address");
b.Property<string>("City");
b.Property<string>("Country");
b.Property<string>("EMail");
b.Property<string>("Name");
b.Property<string>("Phone");
b.Property<string>("Province");
b.Property<string>("Street");
b.Property<int>("ZipCode");
b.HasKey("Id");
b.ToTable("Tenant");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken();
b.Property<string>("Name")
.HasMaxLength(256);
b.Property<string>("NormalizedName")
.HasMaxLength(256);
b.HasKey("Id");
b.HasIndex("NormalizedName")
.IsUnique()
.HasName("RoleNameIndex");
b.ToTable("AspNetRoles");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ClaimType");
b.Property<string>("ClaimValue");
b.Property<string>("RoleId")
.IsRequired();
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("AspNetRoleClaims");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
b.Property<int>("AccessFailedCount");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken();
b.Property<string>("Email")
.HasMaxLength(256);
b.Property<bool>("EmailConfirmed");
b.Property<bool>("LockoutEnabled");
b.Property<DateTimeOffset?>("LockoutEnd");
b.Property<string>("NormalizedEmail")
.HasMaxLength(256);
b.Property<string>("NormalizedUserName")
.HasMaxLength(256);
b.Property<string>("PasswordHash");
b.Property<string>("PhoneNumber");
b.Property<bool>("PhoneNumberConfirmed");
b.Property<string>("SecurityStamp");
b.Property<bool>("TwoFactorEnabled");
b.Property<string>("UserName")
.HasMaxLength(256);
b.HasKey("Id");
b.HasIndex("NormalizedEmail")
.HasName("EmailIndex");
b.HasIndex("NormalizedUserName")
.IsUnique()
.HasName("UserNameIndex");
b.ToTable("AspNetUsers");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ClaimType");
b.Property<string>("ClaimValue");
b.Property<string>("UserId")
.IsRequired();
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("AspNetUserClaims");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.Property<string>("LoginProvider")
.HasMaxLength(128);
b.Property<string>("ProviderKey")
.HasMaxLength(128);
b.Property<string>("ProviderDisplayName");
b.Property<string>("UserId")
.IsRequired();
b.HasKey("LoginProvider", "ProviderKey");
b.HasIndex("UserId");
b.ToTable("AspNetUserLogins");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
{
b.Property<string>("UserId");
b.Property<string>("RoleId");
b.HasKey("UserId", "RoleId");
b.HasIndex("RoleId");
b.ToTable("AspNetUserRoles");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.Property<string>("UserId");
b.Property<string>("LoginProvider")
.HasMaxLength(128);
b.Property<string>("Name")
.HasMaxLength(128);
b.Property<string>("Value");
b.HasKey("UserId", "LoginProvider", "Name");
b.ToTable("AspNetUserTokens");
});
modelBuilder.Entity("IoTSharp.Hub.Data.AttributeLatest", b =>
{
b.HasBaseType("IoTSharp.Hub.Data.AttributeData");
b.Property<Guid?>("DeviceId");
b.HasIndex("DeviceId");
b.HasDiscriminator().HasValue("AttributeLatest");
});
modelBuilder.Entity("IoTSharp.Hub.Data.TelemetryData", b =>
{
b.HasBaseType("IoTSharp.Hub.Data.AttributeData");
b.Property<Guid?>("DeviceId")
.HasColumnName("TelemetryData_DeviceId");
b.HasIndex("DeviceId");
b.HasDiscriminator().HasValue("TelemetryData");
});
modelBuilder.Entity("IoTSharp.Hub.Data.TelemetryLatest", b =>
{
b.HasBaseType("IoTSharp.Hub.Data.AttributeData");
b.Property<Guid?>("DeviceId")
.HasColumnName("TelemetryLatest_DeviceId");
b.HasIndex("DeviceId");
b.HasDiscriminator().HasValue("TelemetryLatest");
});
modelBuilder.Entity("IoTSharp.Hub.Data.AttributeData", b =>
{
b.HasOne("IoTSharp.Hub.Data.Device", "Device")
.WithMany("AttributeData")
.HasForeignKey("DeviceId1")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("IoTSharp.Hub.Data.Customer", b =>
{
b.HasOne("IoTSharp.Hub.Data.Tenant", "Tenant")
.WithMany("Customers")
.HasForeignKey("TenantId");
});
modelBuilder.Entity("IoTSharp.Hub.Data.Device", b =>
{
b.HasOne("IoTSharp.Hub.Data.Customer", "Customer")
.WithMany("Devices")
.HasForeignKey("CustomerId");
b.HasOne("IoTSharp.Hub.Data.Tenant", "Tenant")
.WithMany("Devices")
.HasForeignKey("TenantId");
});
modelBuilder.Entity("IoTSharp.Hub.Data.Relationship", b =>
{
b.HasOne("IoTSharp.Hub.Data.Customer", "Customer")
.WithMany()
.HasForeignKey("CustomerId");
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", "Identity")
.WithMany()
.HasForeignKey("IdentityId");
b.HasOne("IoTSharp.Hub.Data.Tenant", "Tenant")
.WithMany()
.HasForeignKey("TenantId");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole")
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole")
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("IoTSharp.Hub.Data.AttributeLatest", b =>
{
b.HasOne("IoTSharp.Hub.Data.Device")
.WithMany("AttributeLatest")
.HasForeignKey("DeviceId");
});
modelBuilder.Entity("IoTSharp.Hub.Data.TelemetryData", b =>
{
b.HasOne("IoTSharp.Hub.Data.Device")
.WithMany("TelemetryData")
.HasForeignKey("DeviceId");
});
modelBuilder.Entity("IoTSharp.Hub.Data.TelemetryLatest", b =>
{
b.HasOne("IoTSharp.Hub.Data.Device")
.WithMany("TelemetryLatest")
.HasForeignKey("DeviceId");
});
#pragma warning restore 612, 618
}
}
}
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace IoTSharp.Hub.Migrations
{
public partial class AddDataTable : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Tenant",
columns: table => new
{
Id = table.Column<Guid>(nullable: false),
Name = table.Column<string>(nullable: true),
EMail = table.Column<string>(nullable: true),
Phone = table.Column<string>(nullable: true),
Country = table.Column<string>(nullable: true),
Province = table.Column<string>(nullable: true),
City = table.Column<string>(nullable: true),
Street = table.Column<string>(nullable: true),
Address = table.Column<string>(nullable: true),
ZipCode = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Tenant", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Customer",
columns: table => new
{
Id = table.Column<Guid>(nullable: false),
Name = table.Column<string>(nullable: true),
Email = table.Column<string>(nullable: true),
Phone = table.Column<string>(nullable: true),
Country = table.Column<string>(nullable: true),
Province = table.Column<string>(nullable: true),
City = table.Column<string>(nullable: true),
Street = table.Column<string>(nullable: true),
Address = table.Column<string>(nullable: true),
ZipCode = table.Column<int>(nullable: false),
TenantId = table.Column<Guid>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Customer", x => x.Id);
table.ForeignKey(
name: "FK_Customer_Tenant_TenantId",
column: x => x.TenantId,
principalTable: "Tenant",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "Device",
columns: table => new
{
Id = table.Column<Guid>(nullable: false),
Name = table.Column<string>(nullable: true),
Type = table.Column<string>(nullable: true),
TenantId = table.Column<Guid>(nullable: true),
CustomerId = table.Column<Guid>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Device", x => x.Id);
table.ForeignKey(
name: "FK_Device_Customer_CustomerId",
column: x => x.CustomerId,
principalTable: "Customer",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_Device_Tenant_TenantId",
column: x => x.TenantId,
principalTable: "Tenant",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "Relationship",
columns: table => new
{
Id = table.Column<Guid>(nullable: false),
IdentityId = table.Column<string>(nullable: true),
TenantId = table.Column<Guid>(nullable: true),
CustomerId = table.Column<Guid>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Relationship", x => x.Id);
table.ForeignKey(
name: "FK_Relationship_Customer_CustomerId",
column: x => x.CustomerId,
principalTable: "Customer",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_Relationship_AspNetUsers_IdentityId",
column: x => x.IdentityId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_Relationship_Tenant_TenantId",
column: x => x.TenantId,
principalTable: "Tenant",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "AttributeData",
columns: table => new
{
Id = table.Column<Guid>(nullable: false),
KeyName = table.Column<string>(nullable: false),
DeviceId1 = table.Column<Guid>(nullable: false),
Type = table.Column<int>(nullable: false),
DateTime = table.Column<DateTime>(nullable: false),
Value_Boolean = table.Column<bool>(nullable: false),
Value_String = table.Column<string>(nullable: true),
Value_Long = table.Column<long>(nullable: false),
Value_Double = table.Column<double>(nullable: false),
Value_Json = table.Column<string>(type: "jsonb", nullable: true),
Value_XML = table.Column<string>(type: "xml", nullable: true),
Value_Binary = table.Column<byte[]>(nullable: true),
Discriminator = table.Column<string>(nullable: false),
DeviceId = table.Column<Guid>(nullable: true),
TelemetryData_DeviceId = table.Column<Guid>(nullable: true),
TelemetryLatest_DeviceId = table.Column<Guid>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AttributeData", x => x.Id);
table.ForeignKey(
name: "FK_AttributeData_Device_DeviceId1",
column: x => x.DeviceId1,
principalTable: "Device",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_AttributeData_Device_DeviceId",
column: x => x.DeviceId,
principalTable: "Device",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_AttributeData_Device_TelemetryData_DeviceId",
column: x => x.TelemetryData_DeviceId,
principalTable: "Device",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_AttributeData_Device_TelemetryLatest_DeviceId",
column: x => x.TelemetryLatest_DeviceId,
principalTable: "Device",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateIndex(
name: "IX_AttributeData_DeviceId1",
table: "AttributeData",
column: "DeviceId1");
migrationBuilder.CreateIndex(
name: "IX_AttributeData_DeviceId",
table: "AttributeData",
column: "DeviceId");
migrationBuilder.CreateIndex(
name: "IX_AttributeData_TelemetryData_DeviceId",
table: "AttributeData",
column: "TelemetryData_DeviceId");
migrationBuilder.CreateIndex(
name: "IX_AttributeData_TelemetryLatest_DeviceId",
table: "AttributeData",
column: "TelemetryLatest_DeviceId");
migrationBuilder.CreateIndex(
name: "IX_Customer_TenantId",
table: "Customer",
column: "TenantId");
migrationBuilder.CreateIndex(
name: "IX_Device_CustomerId",
table: "Device",
column: "CustomerId");
migrationBuilder.CreateIndex(
name: "IX_Device_TenantId",
table: "Device",
column: "TenantId");
migrationBuilder.CreateIndex(
name: "IX_Relationship_CustomerId",
table: "Relationship",
column: "CustomerId");
migrationBuilder.CreateIndex(
name: "IX_Relationship_IdentityId",
table: "Relationship",
column: "IdentityId");
migrationBuilder.CreateIndex(
name: "IX_Relationship_TenantId",
table: "Relationship",
column: "TenantId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "AttributeData");
migrationBuilder.DropTable(
name: "Relationship");
migrationBuilder.DropTable(
name: "Device");
migrationBuilder.DropTable(
name: "Customer");
migrationBuilder.DropTable(
name: "Tenant");
}
}
}
// <auto-generated />
using System;
using IoTSharp.Hub.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace IoTSharp.Hub.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20190103092505_AddDiscriminator")]
partial class AddDiscriminator
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn)
.HasAnnotation("ProductVersion", "2.2.0-rtm-35687")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
modelBuilder.Entity("IoTSharp.Hub.Data.Customer", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("Address");
b.Property<string>("City");
b.Property<string>("Country");
b.Property<string>("Email");
b.Property<string>("Name");
b.Property<string>("Phone");
b.Property<string>("Province");
b.Property<string>("Street");
b.Property<Guid?>("TenantId");
b.Property<int>("ZipCode");
b.HasKey("Id");
b.HasIndex("TenantId");
b.ToTable("Customer");
});
modelBuilder.Entity("IoTSharp.Hub.Data.DataStorage", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd();
b.Property<int>("Catalog");
b.Property<DateTime>("DateTime");
b.Property<Guid>("DeviceId1");
b.Property<string>("KeyName")
.IsRequired();
b.Property<int>("Type");
b.Property<byte[]>("Value_Binary");
b.Property<bool>("Value_Boolean");
b.Property<double>("Value_Double");
b.Property<string>("Value_Json")
.HasColumnType("jsonb");
b.Property<long>("Value_Long");
b.Property<string>("Value_String");
b.Property<string>("Value_XML")
.HasColumnType("xml");
b.HasKey("Id");
b.HasIndex("DeviceId1");
b.ToTable("DataStorage");
b.HasDiscriminator<int>("Catalog").HasValue(0);
});
modelBuilder.Entity("IoTSharp.Hub.Data.Device", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd();
b.Property<Guid?>("CustomerId");
b.Property<string>("Name");
b.Property<Guid?>("TenantId");
b.Property<string>("Type");
b.HasKey("Id");
b.HasIndex("CustomerId");
b.HasIndex("TenantId");
b.ToTable("Device");
});
modelBuilder.Entity("IoTSharp.Hub.Data.Relationship", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd();
b.Property<Guid?>("CustomerId");
b.Property<string>("IdentityId");
b.Property<Guid?>("TenantId");
b.HasKey("Id");
b.HasIndex("CustomerId");
b.HasIndex("IdentityId");
b.HasIndex("TenantId");
b.ToTable("Relationship");
});
modelBuilder.Entity("IoTSharp.Hub.Data.Tenant", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("Address");
b.Property<string>("City");
b.Property<string>("Country");
b.Property<string>("EMail");
b.Property<string>("Name");
b.Property<string>("Phone");
b.Property<string>("Province");
b.Property<string>("Street");
b.Property<int>("ZipCode");
b.HasKey("Id");
b.ToTable("Tenant");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken();
b.Property<string>("Name")
.HasMaxLength(256);
b.Property<string>("NormalizedName")
.HasMaxLength(256);
b.HasKey("Id");
b.HasIndex("NormalizedName")
.IsUnique()
.HasName("RoleNameIndex");
b.ToTable("AspNetRoles");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ClaimType");
b.Property<string>("ClaimValue");
b.Property<string>("RoleId")
.IsRequired();
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("AspNetRoleClaims");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
b.Property<int>("AccessFailedCount");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken();
b.Property<string>("Email")
.HasMaxLength(256);
b.Property<bool>("EmailConfirmed");
b.Property<bool>("LockoutEnabled");
b.Property<DateTimeOffset?>("LockoutEnd");
b.Property<string>("NormalizedEmail")
.HasMaxLength(256);
b.Property<string>("NormalizedUserName")
.HasMaxLength(256);
b.Property<string>("PasswordHash");
b.Property<string>("PhoneNumber");
b.Property<bool>("PhoneNumberConfirmed");
b.Property<string>("SecurityStamp");
b.Property<bool>("TwoFactorEnabled");
b.Property<string>("UserName")
.HasMaxLength(256);
b.HasKey("Id");
b.HasIndex("NormalizedEmail")
.HasName("EmailIndex");
b.HasIndex("NormalizedUserName")
.IsUnique()
.HasName("UserNameIndex");
b.ToTable("AspNetUsers");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ClaimType");
b.Property<string>("ClaimValue");
b.Property<string>("UserId")
.IsRequired();
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("AspNetUserClaims");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.Property<string>("LoginProvider")
.HasMaxLength(128);
b.Property<string>("ProviderKey")
.HasMaxLength(128);
b.Property<string>("ProviderDisplayName");
b.Property<string>("UserId")
.IsRequired();
b.HasKey("LoginProvider", "ProviderKey");
b.HasIndex("UserId");
b.ToTable("AspNetUserLogins");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
{
b.Property<string>("UserId");
b.Property<string>("RoleId");
b.HasKey("UserId", "RoleId");
b.HasIndex("RoleId");
b.ToTable("AspNetUserRoles");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.Property<string>("UserId");
b.Property<string>("LoginProvider")
.HasMaxLength(128);
b.Property<string>("Name")
.HasMaxLength(128);
b.Property<string>("Value");
b.HasKey("UserId", "LoginProvider", "Name");
b.ToTable("AspNetUserTokens");
});
modelBuilder.Entity("IoTSharp.Hub.Data.AttributeData", b =>
{
b.HasBaseType("IoTSharp.Hub.Data.DataStorage");
b.HasDiscriminator().HasValue(1);
});
modelBuilder.Entity("IoTSharp.Hub.Data.AttributeLatest", b =>
{
b.HasBaseType("IoTSharp.Hub.Data.DataStorage");
b.Property<Guid?>("DeviceId");
b.HasIndex("DeviceId");
b.HasDiscriminator().HasValue(2);
});
modelBuilder.Entity("IoTSharp.Hub.Data.TelemetryData", b =>
{
b.HasBaseType("IoTSharp.Hub.Data.DataStorage");
b.Property<Guid?>("DeviceId")
.HasColumnName("TelemetryData_DeviceId");
b.HasIndex("DeviceId");
b.HasDiscriminator().HasValue(3);
});
modelBuilder.Entity("IoTSharp.Hub.Data.TelemetryLatest", b =>
{
b.HasBaseType("IoTSharp.Hub.Data.DataStorage");
b.Property<Guid?>("DeviceId")
.HasColumnName("TelemetryLatest_DeviceId");
b.HasIndex("DeviceId");
b.HasDiscriminator().HasValue(4);
});
modelBuilder.Entity("IoTSharp.Hub.Data.Customer", b =>
{
b.HasOne("IoTSharp.Hub.Data.Tenant", "Tenant")
.WithMany("Customers")
.HasForeignKey("TenantId");
});
modelBuilder.Entity("IoTSharp.Hub.Data.DataStorage", b =>
{
b.HasOne("IoTSharp.Hub.Data.Device", "Device")
.WithMany("AttributeData")
.HasForeignKey("DeviceId1")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("IoTSharp.Hub.Data.Device", b =>
{
b.HasOne("IoTSharp.Hub.Data.Customer", "Customer")
.WithMany("Devices")
.HasForeignKey("CustomerId");
b.HasOne("IoTSharp.Hub.Data.Tenant", "Tenant")
.WithMany("Devices")
.HasForeignKey("TenantId");
});
modelBuilder.Entity("IoTSharp.Hub.Data.Relationship", b =>
{
b.HasOne("IoTSharp.Hub.Data.Customer", "Customer")
.WithMany()
.HasForeignKey("CustomerId");
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", "Identity")
.WithMany()
.HasForeignKey("IdentityId");
b.HasOne("IoTSharp.Hub.Data.Tenant", "Tenant")
.WithMany()
.HasForeignKey("TenantId");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole")
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole")
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("IoTSharp.Hub.Data.AttributeLatest", b =>
{
b.HasOne("IoTSharp.Hub.Data.Device")
.WithMany("AttributeLatest")
.HasForeignKey("DeviceId");
});
modelBuilder.Entity("IoTSharp.Hub.Data.TelemetryData", b =>
{
b.HasOne("IoTSharp.Hub.Data.Device")
.WithMany("TelemetryData")
.HasForeignKey("DeviceId");
});
modelBuilder.Entity("IoTSharp.Hub.Data.TelemetryLatest", b =>
{
b.HasOne("IoTSharp.Hub.Data.Device")
.WithMany("TelemetryLatest")
.HasForeignKey("DeviceId");
});
#pragma warning restore 612, 618
}
}
}
using Microsoft.EntityFrameworkCore.Migrations;
namespace IoTSharp.Hub.Migrations
{
public partial class AddDiscriminator : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_AttributeData_Device_DeviceId1",
table: "AttributeData");
migrationBuilder.DropForeignKey(
name: "FK_AttributeData_Device_DeviceId",
table: "AttributeData");
migrationBuilder.DropForeignKey(
name: "FK_AttributeData_Device_TelemetryData_DeviceId",
table: "AttributeData");
migrationBuilder.DropForeignKey(
name: "FK_AttributeData_Device_TelemetryLatest_DeviceId",
table: "AttributeData");
migrationBuilder.DropPrimaryKey(
name: "PK_AttributeData",
table: "AttributeData");
migrationBuilder.DropColumn(
name: "Discriminator",
table: "AttributeData");
migrationBuilder.RenameTable(
name: "AttributeData",
newName: "DataStorage");
migrationBuilder.RenameIndex(
name: "IX_AttributeData_TelemetryLatest_DeviceId",
table: "DataStorage",
newName: "IX_DataStorage_TelemetryLatest_DeviceId");
migrationBuilder.RenameIndex(
name: "IX_AttributeData_TelemetryData_DeviceId",
table: "DataStorage",
newName: "IX_DataStorage_TelemetryData_DeviceId");
migrationBuilder.RenameIndex(
name: "IX_AttributeData_DeviceId",
table: "DataStorage",
newName: "IX_DataStorage_DeviceId");
migrationBuilder.RenameIndex(
name: "IX_AttributeData_DeviceId1",
table: "DataStorage",
newName: "IX_DataStorage_DeviceId1");
migrationBuilder.AddColumn<int>(
name: "Catalog",
table: "DataStorage",
nullable: false,
defaultValue: 0);
migrationBuilder.AddPrimaryKey(
name: "PK_DataStorage",
table: "DataStorage",
column: "Id");
migrationBuilder.AddForeignKey(
name: "FK_DataStorage_Device_DeviceId",
table: "DataStorage",
column: "DeviceId",
principalTable: "Device",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_DataStorage_Device_DeviceId1",
table: "DataStorage",
column: "DeviceId1",
principalTable: "Device",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_DataStorage_Device_TelemetryData_DeviceId",
table: "DataStorage",
column: "TelemetryData_DeviceId",
principalTable: "Device",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_DataStorage_Device_TelemetryLatest_DeviceId",
table: "DataStorage",
column: "TelemetryLatest_DeviceId",
principalTable: "Device",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_DataStorage_Device_DeviceId",
table: "DataStorage");
migrationBuilder.DropForeignKey(
name: "FK_DataStorage_Device_DeviceId1",
table: "DataStorage");
migrationBuilder.DropForeignKey(
name: "FK_DataStorage_Device_TelemetryData_DeviceId",
table: "DataStorage");
migrationBuilder.DropForeignKey(
name: "FK_DataStorage_Device_TelemetryLatest_DeviceId",
table: "DataStorage");
migrationBuilder.DropPrimaryKey(
name: "PK_DataStorage",
table: "DataStorage");
migrationBuilder.DropColumn(
name: "Catalog",
table: "DataStorage");
migrationBuilder.RenameTable(
name: "DataStorage",
newName: "AttributeData");
migrationBuilder.RenameIndex(
name: "IX_DataStorage_TelemetryLatest_DeviceId",
table: "AttributeData",
newName: "IX_AttributeData_TelemetryLatest_DeviceId");
migrationBuilder.RenameIndex(
name: "IX_DataStorage_TelemetryData_DeviceId",
table: "AttributeData",
newName: "IX_AttributeData_TelemetryData_DeviceId");
migrationBuilder.RenameIndex(
name: "IX_DataStorage_DeviceId1",
table: "AttributeData",
newName: "IX_AttributeData_DeviceId1");
migrationBuilder.RenameIndex(
name: "IX_DataStorage_DeviceId",
table: "AttributeData",
newName: "IX_AttributeData_DeviceId");
migrationBuilder.AddColumn<string>(
name: "Discriminator",
table: "AttributeData",
nullable: false,
defaultValue: "");
migrationBuilder.AddPrimaryKey(
name: "PK_AttributeData",
table: "AttributeData",
column: "Id");
migrationBuilder.AddForeignKey(
name: "FK_AttributeData_Device_DeviceId1",
table: "AttributeData",
column: "DeviceId1",
principalTable: "Device",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_AttributeData_Device_DeviceId",
table: "AttributeData",
column: "DeviceId",
principalTable: "Device",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_AttributeData_Device_TelemetryData_DeviceId",
table: "AttributeData",
column: "TelemetryData_DeviceId",
principalTable: "Device",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_AttributeData_Device_TelemetryLatest_DeviceId",
table: "AttributeData",
column: "TelemetryLatest_DeviceId",
principalTable: "Device",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
}
}
}
......@@ -19,6 +19,151 @@ namespace IoTSharp.Hub.Migrations
.HasAnnotation("ProductVersion", "2.2.0-rtm-35687")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
modelBuilder.Entity("IoTSharp.Hub.Data.Customer", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("Address");
b.Property<string>("City");
b.Property<string>("Country");
b.Property<string>("Email");
b.Property<string>("Name");
b.Property<string>("Phone");
b.Property<string>("Province");
b.Property<string>("Street");
b.Property<Guid?>("TenantId");
b.Property<int>("ZipCode");
b.HasKey("Id");
b.HasIndex("TenantId");
b.ToTable("Customer");
});
modelBuilder.Entity("IoTSharp.Hub.Data.DataStorage", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd();
b.Property<int>("Catalog");
b.Property<DateTime>("DateTime");
b.Property<Guid>("DeviceId1");
b.Property<string>("KeyName")
.IsRequired();
b.Property<int>("Type");
b.Property<byte[]>("Value_Binary");
b.Property<bool>("Value_Boolean");
b.Property<double>("Value_Double");
b.Property<string>("Value_Json")
.HasColumnType("jsonb");
b.Property<long>("Value_Long");
b.Property<string>("Value_String");
b.Property<string>("Value_XML")
.HasColumnType("xml");
b.HasKey("Id");
b.HasIndex("DeviceId1");
b.ToTable("DataStorage");
b.HasDiscriminator<int>("Catalog").HasValue(0);
});
modelBuilder.Entity("IoTSharp.Hub.Data.Device", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd();
b.Property<Guid?>("CustomerId");
b.Property<string>("Name");
b.Property<Guid?>("TenantId");
b.Property<string>("Type");
b.HasKey("Id");
b.HasIndex("CustomerId");
b.HasIndex("TenantId");
b.ToTable("Device");
});
modelBuilder.Entity("IoTSharp.Hub.Data.Relationship", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd();
b.Property<Guid?>("CustomerId");
b.Property<string>("IdentityId");
b.Property<Guid?>("TenantId");
b.HasKey("Id");
b.HasIndex("CustomerId");
b.HasIndex("IdentityId");
b.HasIndex("TenantId");
b.ToTable("Relationship");
});
modelBuilder.Entity("IoTSharp.Hub.Data.Tenant", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("Address");
b.Property<string>("City");
b.Property<string>("Country");
b.Property<string>("EMail");
b.Property<string>("Name");
b.Property<string>("Phone");
b.Property<string>("Province");
b.Property<string>("Street");
b.Property<int>("ZipCode");
b.HasKey("Id");
b.ToTable("Tenant");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
{
b.Property<string>("Id")
......@@ -180,6 +325,89 @@ namespace IoTSharp.Hub.Migrations
b.ToTable("AspNetUserTokens");
});
modelBuilder.Entity("IoTSharp.Hub.Data.AttributeData", b =>
{
b.HasBaseType("IoTSharp.Hub.Data.DataStorage");
b.HasDiscriminator().HasValue(1);
});
modelBuilder.Entity("IoTSharp.Hub.Data.AttributeLatest", b =>
{
b.HasBaseType("IoTSharp.Hub.Data.DataStorage");
b.Property<Guid?>("DeviceId");
b.HasIndex("DeviceId");
b.HasDiscriminator().HasValue(2);
});
modelBuilder.Entity("IoTSharp.Hub.Data.TelemetryData", b =>
{
b.HasBaseType("IoTSharp.Hub.Data.DataStorage");
b.Property<Guid?>("DeviceId")
.HasColumnName("TelemetryData_DeviceId");
b.HasIndex("DeviceId");
b.HasDiscriminator().HasValue(3);
});
modelBuilder.Entity("IoTSharp.Hub.Data.TelemetryLatest", b =>
{
b.HasBaseType("IoTSharp.Hub.Data.DataStorage");
b.Property<Guid?>("DeviceId")
.HasColumnName("TelemetryLatest_DeviceId");
b.HasIndex("DeviceId");
b.HasDiscriminator().HasValue(4);
});
modelBuilder.Entity("IoTSharp.Hub.Data.Customer", b =>
{
b.HasOne("IoTSharp.Hub.Data.Tenant", "Tenant")
.WithMany("Customers")
.HasForeignKey("TenantId");
});
modelBuilder.Entity("IoTSharp.Hub.Data.DataStorage", b =>
{
b.HasOne("IoTSharp.Hub.Data.Device", "Device")
.WithMany("AttributeData")
.HasForeignKey("DeviceId1")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("IoTSharp.Hub.Data.Device", b =>
{
b.HasOne("IoTSharp.Hub.Data.Customer", "Customer")
.WithMany("Devices")
.HasForeignKey("CustomerId");
b.HasOne("IoTSharp.Hub.Data.Tenant", "Tenant")
.WithMany("Devices")
.HasForeignKey("TenantId");
});
modelBuilder.Entity("IoTSharp.Hub.Data.Relationship", b =>
{
b.HasOne("IoTSharp.Hub.Data.Customer", "Customer")
.WithMany()
.HasForeignKey("CustomerId");
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", "Identity")
.WithMany()
.HasForeignKey("IdentityId");
b.HasOne("IoTSharp.Hub.Data.Tenant", "Tenant")
.WithMany()
.HasForeignKey("TenantId");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole")
......@@ -224,6 +452,27 @@ namespace IoTSharp.Hub.Migrations
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("IoTSharp.Hub.Data.AttributeLatest", b =>
{
b.HasOne("IoTSharp.Hub.Data.Device")
.WithMany("AttributeLatest")
.HasForeignKey("DeviceId");
});
modelBuilder.Entity("IoTSharp.Hub.Data.TelemetryData", b =>
{
b.HasOne("IoTSharp.Hub.Data.Device")
.WithMany("TelemetryData")
.HasForeignKey("DeviceId");
});
modelBuilder.Entity("IoTSharp.Hub.Data.TelemetryLatest", b =>
{
b.HasOne("IoTSharp.Hub.Data.Device")
.WithMany("TelemetryLatest")
.HasForeignKey("DeviceId");
});
#pragma warning restore 612, 618
}
}
......
......@@ -8,10 +8,8 @@ using System.Threading.Tasks;
namespace IoTSharp.Hub.Data
{
public class TelemetryData : AttributeData
public class TelemetryData : DataStorage
{
[Required]
public Device Device { get; set; }
}
}
......@@ -8,10 +8,9 @@ using System.Threading.Tasks;
namespace IoTSharp.Hub.Data
{
public class TelemetryLatest : AttributeData
public class TelemetryLatest : DataStorage
{
[Required]
public Device Device { get; set; }
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册