46 lines
1.4 KiB
C#
46 lines
1.4 KiB
C#
using Hncore.Infrastructure.EF;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using System;
|
|
|
|
namespace Hncore.Pass.OSS.Domain
|
|
{
|
|
public partial class CourseContext : DbContextBase
|
|
{
|
|
IHttpContextAccessor _httpContextAccessor;
|
|
/// <summary>
|
|
/// 构造函数
|
|
/// </summary>
|
|
/// <param name="options">上下文实体</param>
|
|
/// <param name="httpContextAccessor">http请求上下文</param>
|
|
public CourseContext(DbContextOptions<CourseContext> options, IHttpContextAccessor httpContextAccessor) :
|
|
base(options, httpContextAccessor)
|
|
{
|
|
}
|
|
|
|
|
|
public virtual DbSet<Asset> Asset { get; set; }
|
|
public virtual DbSet<AssetGroup> AssetGroup { get; set; }
|
|
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
{
|
|
modelBuilder.Entity<Asset>(entity =>
|
|
{
|
|
entity.ToTable("asset");
|
|
entity.HasKey(p => p.Id);
|
|
entity.Property(e => e.Id).ValueGeneratedOnAdd();
|
|
});
|
|
|
|
modelBuilder.Entity<AssetGroup>(entity =>
|
|
{
|
|
entity.ToTable("asset_group");
|
|
entity.HasKey(p => p.Id);
|
|
entity.Property(e => e.Id).ValueGeneratedOnAdd();
|
|
|
|
});
|
|
base.OnModelCreating(modelBuilder);
|
|
}
|
|
}
|
|
}
|