소스 검색

update Admin.NET/Admin.NET.Core/SqlSugar/SqlSugarSetup.cs.
解决pgsql中,业务添加框架的种子数据时候,类映射了多个类型的问题bug(本bug是sqlsugar作者提供的解决方案)

Signed-off-by: MrXiaoZ <362270511@qq.com>

MrXiaoZ 3 년 전
부모
커밋
e0dae94da8
1개의 변경된 파일3개의 추가작업 그리고 2개의 파일을 삭제
  1. 3 2
      Admin.NET/Admin.NET.Core/SqlSugar/SqlSugarSetup.cs

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

@@ -220,13 +220,14 @@ public static class SqlSugarSetup
             }
             if (seedDataTable.Columns.Contains(SqlSugarConst.PrimaryKey))
             {
-                var storage = db2.Storageable(seedDataTable).WhereColumns(SqlSugarConst.PrimaryKey).ToStorage();
+                //解决pgsql中,业务添加框架的种子数据时候,类映射了多个类型的问题bug(本bug是sqlsugar作者提供的解决方案)
+                var storage = db2.CopyNew().Storageable(seedDataTable).WhereColumns(SqlSugarConst.PrimaryKey).ToStorage();
                 storage.AsInsertable.ExecuteCommand();
                 storage.AsUpdateable.ExecuteCommand();
             }
             else // 没有主键或者不是预定义的主键(有重复的可能)
             {
-                var storage = db2.Storageable(seedDataTable).ToStorage();
+                var storage = db2.CopyNew().Storageable(seedDataTable).ToStorage();
                 storage.AsInsertable.ExecuteCommand();
             }
         }