初始提交
This commit is contained in:
38
Services/Hncore.Pass.Manage/Repository/EfDbContext.cs
Normal file
38
Services/Hncore.Pass.Manage/Repository/EfDbContext.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using Hncore.Infrastructure.EF;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Hncore.Pass.Manage.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// EF数据库上下文类
|
||||
/// </summary>
|
||||
///
|
||||
public class EfDbContext : DbContextBase
|
||||
{
|
||||
public DbContext DbContext => this;
|
||||
|
||||
/// <summary>
|
||||
/// 构造函数
|
||||
/// </summary>
|
||||
/// <param name="options">上下文实体</param>
|
||||
/// <param name="httpContextAccessor">http请求上下文</param>
|
||||
public EfDbContext(DbContextOptions<EfDbContext> options, IHttpContextAccessor httpContextAccessor) :
|
||||
base(options, httpContextAccessor)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 创建映射
|
||||
/// </summary>
|
||||
/// <param name="modelBuilder"></param>
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.AutoMap(typeof(EfDbContext));
|
||||
|
||||
base.OnModelCreating(modelBuilder);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user