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