Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
IoTSharp
IoTSharp
提交
fb7f7e18
IoTSharp
项目概览
IoTSharp
/
IoTSharp
9 个月 前同步成功
通知
15
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
IoTSharp
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
fb7f7e18
编写于
12月 17, 2018
作者:
麦壳饼
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
dotnet ef migrations add AddBaseTable
上级
f5127aca
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
936 addition
and
25 deletion
+936
-25
IoTSharp.Hub/Data/ApplicationDbContext.cs
IoTSharp.Hub/Data/ApplicationDbContext.cs
+2
-1
IoTSharp.Hub/Data/Migrations/20181217155621_AddBaseTable.Designer.cs
...b/Data/Migrations/20181217155621_AddBaseTable.Designer.cs
+436
-0
IoTSharp.Hub/Data/Migrations/20181217155621_AddBaseTable.cs
IoTSharp.Hub/Data/Migrations/20181217155621_AddBaseTable.cs
+268
-0
IoTSharp.Hub/Data/Migrations/ApplicationDbContextModelSnapshot.cs
....Hub/Data/Migrations/ApplicationDbContextModelSnapshot.cs
+211
-12
IoTSharp.Hub/Extensions/IoTSharpExtension.cs
IoTSharp.Hub/Extensions/IoTSharpExtension.cs
+14
-2
IoTSharp.Hub/Startup.cs
IoTSharp.Hub/Startup.cs
+2
-1
IoTSharp.Hub/appsettings.Development.json
IoTSharp.Hub/appsettings.Development.json
+3
-3
IoTSharp.sln
IoTSharp.sln
+0
-6
healthchecksdb
healthchecksdb
+0
-0
未找到文件。
IoTSharp.Hub/Data/ApplicationDbContext.cs
浏览文件 @
fb7f7e18
...
...
@@ -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
);
...
...
IoTSharp.Hub/Data/Migrations/20181217155621_AddBaseTable.Designer.cs
0 → 100644
浏览文件 @
fb7f7e18
// <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
}
}
}
IoTSharp.Hub/Data/Migrations/20181217155621_AddBaseTable.cs
0 → 100644
浏览文件 @
fb7f7e18
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"
);
}
}
}
IoTSharp.Hub/Data/Migrations/ApplicationDbContextModelSnapshot.cs
浏览文件 @
fb7f7e18
...
...
@@ -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
=>
{
...
...
IoTSharp.Hub/Extensions/IoTSharpExtension.cs
浏览文件 @
fb7f7e18
...
...
@@ -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
(
...
...
IoTSharp.Hub/Startup.cs
浏览文件 @
fb7f7e18
...
...
@@ -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
IoTSharp.Hub/appsettings.Development.json
浏览文件 @
fb7f7e18
...
...
@@ -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"
,
...
...
IoTSharp.sln
浏览文件 @
fb7f7e18
...
...
@@ -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
...
...
healthchecksdb
0 → 100644
浏览文件 @
fb7f7e18
文件已添加
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录