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