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

dotnet ef migrations add AddBaseTable

上级 f5127aca
......@@ -30,7 +30,8 @@ namespace IoTSharp.Hub.Data
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Customer>()
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<Customer>()
.HasOne(p => p.Tenant)
.WithMany(b => b.Customers);
......
// <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.Data.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20181217155621_AddBaseTable")]
partial class AddBaseTable
{
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.ClientSideAttribute", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("Name");
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.ToTable("ClientSideAttribute");
});
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>("UseId")
.ValueGeneratedOnAdd();
b.Property<Guid>("CustomerId");
b.Property<Guid>("TenantId");
b.HasKey("UseId");
b.ToTable("Relationship");
});
modelBuilder.Entity("IoTSharp.Hub.Data.ServerSideAttribute", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("Name");
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.ToTable("ServerSideAttribute");
});
modelBuilder.Entity("IoTSharp.Hub.Data.SharedSideAttribute", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("Name");
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.ToTable("SharedSideAttribute");
});
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.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("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);
});
#pragma warning restore 612, 618
}
}
}
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace IoTSharp.Hub.Data.Migrations
{
public partial class AddBaseTable : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "UserNameIndex",
table: "AspNetUsers");
migrationBuilder.DropIndex(
name: "RoleNameIndex",
table: "AspNetRoles");
migrationBuilder.AlterColumn<int>(
name: "Id",
table: "AspNetUserClaims",
nullable: false,
oldClrType: typeof(int))
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn);
migrationBuilder.AlterColumn<int>(
name: "Id",
table: "AspNetRoleClaims",
nullable: false,
oldClrType: typeof(int))
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn);
migrationBuilder.CreateTable(
name: "ClientSideAttribute",
columns: table => new
{
Id = table.Column<Guid>(nullable: false),
Name = table.Column<string>(nullable: true),
Type = table.Column<int>(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)
},
constraints: table =>
{
table.PrimaryKey("PK_ClientSideAttribute", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Relationship",
columns: table => new
{
UseId = table.Column<Guid>(nullable: false),
CustomerId = table.Column<Guid>(nullable: false),
TenantId = table.Column<Guid>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Relationship", x => x.UseId);
});
migrationBuilder.CreateTable(
name: "ServerSideAttribute",
columns: table => new
{
Id = table.Column<Guid>(nullable: false),
Name = table.Column<string>(nullable: true),
Type = table.Column<int>(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)
},
constraints: table =>
{
table.PrimaryKey("PK_ServerSideAttribute", x => x.Id);
});
migrationBuilder.CreateTable(
name: "SharedSideAttribute",
columns: table => new
{
Id = table.Column<Guid>(nullable: false),
Name = table.Column<string>(nullable: true),
Type = table.Column<int>(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)
},
constraints: table =>
{
table.PrimaryKey("PK_SharedSideAttribute", x => x.Id);
});
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.CreateIndex(
name: "UserNameIndex",
table: "AspNetUsers",
column: "NormalizedUserName",
unique: true);
migrationBuilder.CreateIndex(
name: "RoleNameIndex",
table: "AspNetRoles",
column: "NormalizedName",
unique: true);
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");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "ClientSideAttribute");
migrationBuilder.DropTable(
name: "Device");
migrationBuilder.DropTable(
name: "Relationship");
migrationBuilder.DropTable(
name: "ServerSideAttribute");
migrationBuilder.DropTable(
name: "SharedSideAttribute");
migrationBuilder.DropTable(
name: "Customer");
migrationBuilder.DropTable(
name: "Tenant");
migrationBuilder.DropIndex(
name: "UserNameIndex",
table: "AspNetUsers");
migrationBuilder.DropIndex(
name: "RoleNameIndex",
table: "AspNetRoles");
migrationBuilder.AlterColumn<int>(
name: "Id",
table: "AspNetUserClaims",
nullable: false,
oldClrType: typeof(int))
.OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn);
migrationBuilder.AlterColumn<int>(
name: "Id",
table: "AspNetRoleClaims",
nullable: false,
oldClrType: typeof(int))
.OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn);
migrationBuilder.CreateIndex(
name: "UserNameIndex",
table: "AspNetUsers",
column: "NormalizedUserName",
unique: true,
filter: "[NormalizedUserName] IS NOT NULL");
migrationBuilder.CreateIndex(
name: "RoleNameIndex",
table: "AspNetRoles",
column: "NormalizedName",
unique: true,
filter: "[NormalizedName] IS NOT NULL");
}
}
}
......@@ -3,8 +3,8 @@ using System;
using IoTSharp.Hub.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace IoTSharp.Hub.Data.Migrations
{
......@@ -15,9 +15,195 @@ namespace IoTSharp.Hub.Data.Migrations
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "2.1.4-rtm-31024")
.HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn)
.HasAnnotation("ProductVersion", "2.2.0-rtm-35687")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
modelBuilder.Entity("IoTSharp.Hub.Data.ClientSideAttribute", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("Name");
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.ToTable("ClientSideAttribute");
});
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>("UseId")
.ValueGeneratedOnAdd();
b.Property<Guid>("CustomerId");
b.Property<Guid>("TenantId");
b.HasKey("UseId");
b.ToTable("Relationship");
});
modelBuilder.Entity("IoTSharp.Hub.Data.ServerSideAttribute", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("Name");
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.ToTable("ServerSideAttribute");
});
modelBuilder.Entity("IoTSharp.Hub.Data.SharedSideAttribute", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("Name");
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.ToTable("SharedSideAttribute");
});
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 =>
{
......@@ -37,8 +223,7 @@ namespace IoTSharp.Hub.Data.Migrations
b.HasIndex("NormalizedName")
.IsUnique()
.HasName("RoleNameIndex")
.HasFilter("[NormalizedName] IS NOT NULL");
.HasName("RoleNameIndex");
b.ToTable("AspNetRoles");
});
......@@ -46,8 +231,7 @@ namespace IoTSharp.Hub.Data.Migrations
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
.ValueGeneratedOnAdd();
b.Property<string>("ClaimType");
......@@ -108,8 +292,7 @@ namespace IoTSharp.Hub.Data.Migrations
b.HasIndex("NormalizedUserName")
.IsUnique()
.HasName("UserNameIndex")
.HasFilter("[NormalizedUserName] IS NOT NULL");
.HasName("UserNameIndex");
b.ToTable("AspNetUsers");
});
......@@ -117,8 +300,7 @@ namespace IoTSharp.Hub.Data.Migrations
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
.ValueGeneratedOnAdd();
b.Property<string>("ClaimType");
......@@ -184,6 +366,23 @@ namespace IoTSharp.Hub.Data.Migrations
b.ToTable("AspNetUserTokens");
});
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("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{
......
......@@ -25,30 +25,42 @@ namespace IoTSharp.Hub
case "mssql":
services.AddEntityFrameworkSqlServer();
services.AddDbContext<ApplicationDbContext>(options => options.UseSqlServer(_ConnectionString), ServiceLifetime.Transient);
#if WithHealthChecks
services.AddHealthChecks().AddSqlServer(_ConnectionString, name: "database").AddMQTTChatHealthChecks();
#endif
break;
case "npgsql":
services.AddEntityFrameworkNpgsql();
services.AddDbContext<ApplicationDbContext>(options => options.UseNpgsql(_ConnectionString), ServiceLifetime.Transient);
#if WithHealthChecks
services.AddHealthChecks().AddNpgSql(_ConnectionString, name: "database").AddMQTTChatHealthChecks();
#endif
break;
case "memory":
services.AddEntityFrameworkInMemoryDatabase();
services.AddDbContext<ApplicationDbContext>(options => options.UseInMemoryDatabase(nameof(ApplicationDbContext)), ServiceLifetime.Transient);
#if WithHealthChecks
services.AddHealthChecks().AddMQTTChatHealthChecks();
#endif
break;
case "sqlite":
default:
services.AddEntityFrameworkSqlite();
services.AddDbContext<ApplicationDbContext>(options => options.UseSqlite(_ConnectionString), ServiceLifetime.Transient);
#if WithHealthChecks
services.AddHealthChecks().AddSqlite(_ConnectionString, name: "database").AddMQTTChatHealthChecks();
#endif
break;
}
services.AddHealthChecksUI();
#if WithHealthChecks
services.AddHealthChecksUI();
#endif
}
#if WithHealthChecks
internal static void UseIotSharpHealthChecks(this IApplicationBuilder app)
{
app.UseHealthChecksUI();
......@@ -69,7 +81,7 @@ namespace IoTSharp.Hub
});
});
}
#endif
private static string GetFullPathName(string filename)
{
FileInfo fi = new FileInfo(System.IO.Path.Combine(
......
......@@ -106,8 +106,9 @@ namespace IoTSharp.Hub
var externalPath = request.Headers.ContainsKey("X-External-Path") ? request.Headers["X-External-Path"].First() : "";
return externalPath + internalUiRoute;
});
#if WithHealthChecks
app.UseIotSharpHealthChecks();
#endif
}
}
}
\ No newline at end of file
......@@ -6,10 +6,10 @@
"Microsoft": "Information"
}
},
"DataBase": "sqlite",
"DataBase": "npgsql",
"ConnectionStrings": {
"mssql": "Server=localhost;Database=MQTTChat;Trusted_Connection=True;MultipleActiveResultSets=true",
"npgsql": "Server=localhost;Database=MQTTChat;Username=postgres;Password=future;",
"mssql": "Server=localhost;Database=IoTSharp;Trusted_Connection=True;MultipleActiveResultSets=true",
"npgsql": "Server=localhost;Database=IoTSharp;Username=postgres;Password=future;",
"sqlite": "Data Source=:memory:"
},
"JwtKey": "kissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissme",
......
......@@ -12,8 +12,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
README.md = README.md
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebApplication1", "WebApplication1\WebApplication1.csproj", "{4B89CAE2-66F7-4C95-B701-AE48810F2051}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
......@@ -24,10 +22,6 @@ Global
{260081B3-E2EA-4BA0-8322-E3894907585E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{260081B3-E2EA-4BA0-8322-E3894907585E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{260081B3-E2EA-4BA0-8322-E3894907585E}.Release|Any CPU.Build.0 = Release|Any CPU
{4B89CAE2-66F7-4C95-B701-AE48810F2051}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4B89CAE2-66F7-4C95-B701-AE48810F2051}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4B89CAE2-66F7-4C95-B701-AE48810F2051}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4B89CAE2-66F7-4C95-B701-AE48810F2051}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......
文件已添加
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册