修复sqlserver codefirst的问题

This commit is contained in:
陈淳
2022-11-02 16:36:08 +08:00
parent 32ed6c3e97
commit 23a9d02aba
3 changed files with 7 additions and 6 deletions

View File

@@ -104,8 +104,9 @@ namespace Yi.Framework.WebCore.DbExtend
var typeList = Common.Helper.AssemblyHelper.GetClass("Yi.Framework.Model");
foreach (var t in typeList)
{
//扫描如果存在SugarTable特性直接codefirst
if (t.GetCustomAttributes(false).Any(a => a.GetType().Equals(typeof(SugarTable))))
//扫描如果存在SugarTable特性 并且 不是分表模型直接codefirst
if (t.GetCustomAttributes(false).Any(a => a.GetType().Equals(typeof(SugarTable))
&& !t.GetCustomAttributes(false).Any(a=>a.GetType().Equals(typeof(SplitTableAttribute)))))
{
_Db.CodeFirst.SetStringDefaultLength(200).InitTables(t);//这样一个表就能成功创建了
}