支持表自动迁移 & 优化ServiceProvider获取 & 包版本升级
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
using Infrastructure;
|
||||
using Infrastructure.Helper;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using SqlSugar;
|
||||
using SqlSugar.IOC;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using ZR.Admin.WebApi.Framework;
|
||||
using ZR.Model.System;
|
||||
|
||||
@@ -24,6 +26,9 @@ namespace ZR.Admin.WebApi.Extensions
|
||||
//仅本人数据权限
|
||||
public static string DATA_SCOPE_SELF = "5";
|
||||
|
||||
|
||||
|
||||
|
||||
public static void AddDb(IConfiguration Configuration)
|
||||
{
|
||||
string connStr = Configuration.GetConnectionString("conn_db");
|
||||
@@ -83,6 +88,18 @@ namespace ZR.Admin.WebApi.Extensions
|
||||
};
|
||||
#endregion
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public static void InitDb(this IServiceProvider service)
|
||||
{
|
||||
var db = DbScoped.SugarScope;
|
||||
db.DbMaintenance.CreateDatabase();
|
||||
//db.CodeFirst.
|
||||
var baseType = typeof(SysBase);
|
||||
|
||||
var entityes = AssemblyUtils.GetAllTypes().Where(p => !p.IsAbstract && p != baseType && /*p.IsAssignableTo(baseType) && */p.GetCustomAttribute<SugarTable>()!=null).ToArray();
|
||||
db.CodeFirst.SetStringDefaultLength(512).InitTables(entityes);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user