40 lines
1.1 KiB
C#
40 lines
1.1 KiB
C#
|
|
|
|
namespace MiaoYu.Repository.ChatAI.Admin
|
|
{
|
|
/// <summary>
|
|
/// 后台管理系统数据库上下文
|
|
/// </summary>
|
|
[DbContextConfig($"Repository.*.Entities.*")]
|
|
public class ChatAdminDbContext : DbContext, IBaseDbContext
|
|
{
|
|
/// <summary>
|
|
/// 工作单元
|
|
/// </summary>
|
|
public IUnitOfWork UnitOfWork { get; }
|
|
|
|
public ChatAdminDbContext(DbContextOptions<ChatAdminDbContext> dbContextOptions) : base(dbContextOptions)
|
|
{
|
|
UnitOfWork = new UnitOfWorkImpl<ChatAdminDbContext>(this);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 模型创建
|
|
/// </summary>
|
|
/// <param name="modelBuilder"></param>
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
{
|
|
var dbContextConfigAttribute = GetType().GetCustomAttribute<DbContextConfigAttribute>()!;
|
|
dbContextConfigAttribute!.OnModelCreating(modelBuilder, dbContextConfigAttribute.GetModelTypes(GetType()));
|
|
|
|
#region 自动迁移种子数据
|
|
|
|
//ModelBuilderExtensions.Seed(modelBuilder);
|
|
|
|
#endregion
|
|
}
|
|
|
|
|
|
}
|
|
}
|