2020-04-10 18:15:11 +08:00
|
|
|
|
using FAuth.DataBase.Tables;
|
2020-03-30 10:12:52 +08:00
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
|
|
|
|
|
namespace FAuth.DataBase
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 数据库
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class FAuthDb:DbContext
|
|
|
|
|
{
|
2020-04-10 18:15:11 +08:00
|
|
|
|
public FAuthDb(DbContextOptions options) : base(options) {
|
2020-04-22 20:59:52 +08:00
|
|
|
|
//Database.EnsureCreatedAsync().Wait();
|
2020-04-10 18:15:11 +08:00
|
|
|
|
}
|
2020-04-14 11:43:48 +08:00
|
|
|
|
|
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder) {
|
|
|
|
|
var mb = modelBuilder;
|
|
|
|
|
mb.Entity<App_RoleGroup>().HasKey(m => new { m.AppId,m.RoleGroupId });
|
|
|
|
|
mb.Entity<RoleGroup_Role>().HasKey(m => new { m.RoleGroupId,m.RoleId });
|
|
|
|
|
mb.Entity<Role_User>().HasKey(m => new { m.RoleId,m.UserId });
|
|
|
|
|
base.OnModelCreating(modelBuilder);
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-10 18:15:11 +08:00
|
|
|
|
/// <summary>
|
2020-04-14 11:43:48 +08:00
|
|
|
|
/// 用户
|
2020-04-10 18:15:11 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
public DbSet<FUser> Users { get; set; }
|
2020-04-14 11:43:48 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 应用信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
public DbSet<Apps> Apps { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 角色组信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
public DbSet<RoleGroup> RoleGroups { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 角色信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
public DbSet<Roles> Roles { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 应用角色组对应关系
|
|
|
|
|
/// </summary>
|
|
|
|
|
public DbSet<App_RoleGroup> App_RoleGroups { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 角色组角色对应关系
|
|
|
|
|
/// </summary>
|
|
|
|
|
public DbSet<RoleGroup_Role> RoleGroup_Roles { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 角色用户对应关系
|
|
|
|
|
/// </summary>
|
|
|
|
|
public DbSet<Role_User> Role_Users { get; set; }
|
2020-03-30 10:12:52 +08:00
|
|
|
|
}
|
|
|
|
|
}
|