fix 控制自动生成表结构
This commit is contained in:
@@ -5,6 +5,7 @@ using Kurisu.Core.DataAccess.Entity;
|
||||
using Kurisu.SqlSugar.Extensions;
|
||||
using Kurisu.SqlSugar.Services;
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Dlhis.Basic.Packs;
|
||||
@@ -55,17 +56,21 @@ public class SqlSugarPack : BaseAppPack
|
||||
|
||||
public override void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
{
|
||||
using var scope = app.ApplicationServices.CreateScope();
|
||||
var db = scope.ServiceProvider.GetService<IDbContext>();
|
||||
var tables = App.ActiveTyps.Where(x => x.IsDefined(typeof(SugarTable), false))
|
||||
.Where(x => !x.IsDefined(typeof(SkipScanAttribute), false))
|
||||
.ToArray();
|
||||
var siGenerate = Configuration.GetSection("SqlSugarOptions").GetValue<bool>("Generate");
|
||||
if (siGenerate)
|
||||
{
|
||||
using var scope = app.ApplicationServices.CreateScope();
|
||||
var db = scope.ServiceProvider.GetService<IDbContext>();
|
||||
var tables = App.ActiveTyps.Where(x => x.IsDefined(typeof(SugarTable), false))
|
||||
.Where(x => !x.IsDefined(typeof(SkipScanAttribute), false))
|
||||
.ToArray();
|
||||
|
||||
db.Client.DbMaintenance.CreateDatabase();
|
||||
db.Client.CodeFirst.InitTables(tables);
|
||||
db.Client.DbMaintenance.CreateDatabase();
|
||||
db.Client.CodeFirst.InitTables(tables);
|
||||
|
||||
var faceDb = db.ChangeDb("face");
|
||||
faceDb.Client.DbMaintenance.CreateDatabase();
|
||||
faceDb.Client.CodeFirst.InitTables<GainfoFaceEntity>();
|
||||
var faceDb = db.ChangeDb("face");
|
||||
faceDb.Client.DbMaintenance.CreateDatabase();
|
||||
faceDb.Client.CodeFirst.InitTables<GainfoFaceEntity>();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user