using Kingdee.CDP.WebApi.SDK;
using Microsoft.EntityFrameworkCore;
using RB_MES_API.Context;
using RB_MES_APICore.Models.Mes;
namespace RB_MES_APICore.Context
{
///
/// MES数据库
///
public class MESContext : DbContext
{
private readonly string _mesSchema;
///
/// 构造函数
///
///
public MESContext(DbContextOptions options) : base(options)
{
_mesSchema = ApiSettingsHelper.GetConfig("MesSchema");
}
///
///
///
///
public void ConfigureServices(IServiceCollection services)
{
var connectionString = ApiSettingsHelper.GetConfig("MES_Conn");
services.AddDbContextPool(options =>
{
options.UseOracle(connectionString, oracleOptionsAction: sqlOptions =>
{
sqlOptions.CommandTimeout(600);
sqlOptions.MaxBatchSize(32767);
});
});
}
///
/// 构建表关系
///
///
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.HasDefaultSchema(_mesSchema);
modelBuilder.Entity().ToTable("TB_PP_WPLAN");
modelBuilder.Entity().HasNoKey();
}
public DbSet TB_PP_WPLANS { get; set; }
}
}