Jelajahi Sumber

种子数据忽略更新,防止数据被覆盖

Signed-off-by: skywolf627 <skywolf627@qq.com>
skywolf627 3 tahun lalu
induk
melakukan
049c135d4b
1 mengubah file dengan 2 tambahan dan 1 penghapusan
  1. 2 1
      Admin.NET/Admin.NET.Core/SqlSugar/SqlSugarSetup.cs

+ 2 - 1
Admin.NET/Admin.NET.Core/SqlSugar/SqlSugarSetup.cs

@@ -220,7 +220,8 @@ public static class SqlSugarSetup
             {
                 var storage = db2.Storageable(seedDataTable).WhereColumns(SqlSugarConst.PrimaryKey).ToStorage();
                 storage.AsInsertable.ExecuteCommand();
-                storage.AsUpdateable.ExecuteCommand();
+                var ignoreUpdate = hasDataMethod.GetCustomAttribute<IgnoreUpdateAttribute>();
+                if (ignoreUpdate == null) storage.AsUpdateable.ExecuteCommand();
             }
             else // 没有主键或者不是预定义的主键(有重复的可能)
             {