diff --git a/Falcon.SugarApi/DatabaseDefinitions/SugarDbContext.cs b/Falcon.SugarApi/DatabaseDefinitions/SugarDbContext.cs
index a05dfc6..5f5dbb1 100644
--- a/Falcon.SugarApi/DatabaseDefinitions/SugarDbContext.cs
+++ b/Falcon.SugarApi/DatabaseDefinitions/SugarDbContext.cs
@@ -4,6 +4,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
+using System.Threading.Tasks;
namespace Falcon.SugarApi.DatabaseDefinitions
{
@@ -175,6 +176,20 @@ namespace Falcon.SugarApi.DatabaseDefinitions
this.UpdateTableStructure(typeof(TableType));
}
+ ///
+ /// 升级表架构并在首次建表后插入初始化数据
+ ///
+ /// 初始化表的模型
+ /// 表名
+ /// 表首次创建后执行的回调
+ public void UpdateTable(string tableName, Action callbackWhenInitTable) {
+ var hasTable = this.DbMaintenance.IsAnyTable(tableName, false);
+ this.CodeFirst.InitTables();
+ if (!hasTable) {
+ callbackWhenInitTable(this);
+ }
+ }
+
#endregion
#region 执行存储过程