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