FalconSSO/FAuth.Database/FAuthDb.cs

53 lines
1.7 KiB
C#
Raw Normal View History

using FAuth.DataBase.Tables;
2020-03-30 10:12:52 +08:00
using Microsoft.EntityFrameworkCore;
namespace FAuth.DataBase
{
/// <summary>
/// 数据库
/// </summary>
public class FAuthDb:DbContext
{
public FAuthDb(DbContextOptions options) : base(options) {
2020-04-22 20:59:52 +08:00
//Database.EnsureCreatedAsync().Wait();
}
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);
}
/// <summary>
/// 用户
/// </summary>
public DbSet<FUser> Users { get; set; }
/// <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
}
}