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>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,8 @@
|
||||
"FaceConnectionString": "server=192.168.199.124;port=3306;userid=root;password=dlhis123;database=face;charset=utf8mb4;",
|
||||
"Timeout": 30,
|
||||
"SlowSqlTime": 1,
|
||||
"EnableSqlLog": false
|
||||
"EnableSqlLog": false,
|
||||
"Generate": false
|
||||
},
|
||||
"SwaggerOptions": {
|
||||
"Enable": true,
|
||||
|
||||
Reference in New Issue
Block a user