Files
jinko.yikatong/Src/Dlhis.ScheduledTask/SqlSugarPack.cs
2024-01-06 17:42:06 +08:00

30 lines
903 B
C#

using Kurisu.AspNetCore.Startup;
using Kurisu.AspNetCore;
using Kurisu.SqlSugar.Extensions;
using SqlSugar;
namespace Dlhis.ScheduledTask
{
public class SqlSugarPack : BaseAppPack
{
public override bool IsBeforeUseRouting { get; }
public override void ConfigureServices(IServiceCollection services)
{
services.AddHttpContextAccessor();
services.AddSqlSugar();
}
public override void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
#if DEBUG
using var scope = app.ApplicationServices.CreateScope();
var db = scope.ServiceProvider.GetService<ISqlSugarClient>();
var tables = App.ActiveTyps.Where(x => x.IsDefined(typeof(SugarTable), false)).ToArray();
db.DbMaintenance.CreateDatabase();
db.CodeFirst.InitTables(tables);
#endif
}
}
}