mirror of
https://gitee.com/ccnetcore/Yi
synced 2026-04-16 14:16:37 +08:00
v1.0.9
This commit is contained in:
@@ -22,10 +22,10 @@ namespace CC.Yi.API
|
|||||||
{
|
{
|
||||||
logger.Debug("正在启动Yi意框架。。。。。。");
|
logger.Debug("正在启动Yi意框架。。。。。。");
|
||||||
var host = CreateHostBuilder(args).Build();
|
var host = CreateHostBuilder(args).Build();
|
||||||
var scope = host.Services.CreateScope();
|
//var scope = host.Services.CreateScope();
|
||||||
var services = scope.ServiceProvider;
|
//var services = scope.ServiceProvider;
|
||||||
var context = services.GetRequiredService<Model.DataContext>();//获取服务
|
//var context = services.GetRequiredService<Model.DataContext>();//获取服务
|
||||||
DbContentFactory.Initialize(context);//调用静态类方法注入
|
//DbContentFactory.Initialize(context);//调用静态类方法注入
|
||||||
host.Run();
|
host.Run();
|
||||||
logger.Info("Yi意框架启动成功!");
|
logger.Info("Yi意框架启动成功!");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,11 +75,21 @@ namespace CC.Yi.API
|
|||||||
}).AddEntityFrameworkStores<DataContext>().AddDefaultTokenProviders();
|
}).AddEntityFrameworkStores<DataContext>().AddDefaultTokenProviders();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void InitData(IServiceProvider serviceProvider)
|
||||||
|
{
|
||||||
|
var serviceScope = serviceProvider.GetRequiredService<IServiceScopeFactory>().CreateScope();
|
||||||
|
|
||||||
|
var context = serviceScope.ServiceProvider.GetService<DataContext>();
|
||||||
|
DbContentFactory.Initialize(context);//调用静态类方法注入
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (env.IsDevelopment())
|
if (env.IsDevelopment())
|
||||||
{
|
{
|
||||||
app.UseDeveloperExceptionPage();
|
app.UseDeveloperExceptionPage();
|
||||||
@@ -99,6 +109,7 @@ namespace CC.Yi.API
|
|||||||
{
|
{
|
||||||
endpoints.MapControllers();
|
endpoints.MapControllers();
|
||||||
});
|
});
|
||||||
|
InitData(app.ApplicationServices);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ namespace CC.Yi.DAL
|
|||||||
public class DbContentFactory
|
public class DbContentFactory
|
||||||
{
|
{
|
||||||
private static DataContext Webcontext;
|
private static DataContext Webcontext;
|
||||||
|
|
||||||
|
|
||||||
public static void Initialize(DataContext webContext)
|
public static void Initialize(DataContext webContext)
|
||||||
{
|
{
|
||||||
Webcontext = webContext;
|
Webcontext = webContext;
|
||||||
|
|||||||
Reference in New Issue
Block a user