AGSSbackend/AGSS/DbSet/UserSet.cs

35 lines
1.1 KiB
C#

using AGSS.Models.Entities;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
namespace AGSS.DbSet
{
public class ApplicationDbContext : IdentityDbContext<UserModel,RoleModel,string>
{
public override DbSet<UserModel> Users { get; set; }
public override DbSet<RoleModel> Roles { get; set; }
public DbSet<DictionaryModel> Dictionaries { get; set; }
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
: base(options)
{
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<DictionaryModel>()
.HasKey(d => d.Uuid); // 假设 Id 是 DictionaryModel 的主键字段
// 在这里添加额外的配置,如果需要的话
// 例如:
// modelBuilder.Entity<UserModel>().ToTable("CustomUsers");
// modelBuilder.Entity<RoleModel>().ToTable("CustomRoles");
}
}
}