diff --git a/Src/Asp.NetCore2/SqlSugar/Abstract/InsertableProvider/SplitInsertable.cs b/Src/Asp.NetCore2/SqlSugar/Abstract/InsertableProvider/SplitInsertable.cs index c1b1e0d65..7e36e98ca 100644 --- a/Src/Asp.NetCore2/SqlSugar/Abstract/InsertableProvider/SplitInsertable.cs +++ b/Src/Asp.NetCore2/SqlSugar/Abstract/InsertableProvider/SplitInsertable.cs @@ -8,6 +8,7 @@ namespace SqlSugar { public class SplitInsertable where T:class ,new() { + private static readonly object SplitLockObj = new object(); public SqlSugarProvider Context; internal SplitTableContext Helper; public EntityInfo EntityInfo; @@ -215,10 +216,16 @@ namespace SqlSugar { if (!this.Context.DbMaintenance.IsAnyTable(item.Key, false)) { - if (item.Value != null) + lock (SplitLockObj) { - this.Context.MappingTables.Add(EntityInfo.EntityName, item.Key); - this.Context.CodeFirst.InitTables(); + if (!this.Context.DbMaintenance.IsAnyTable(item.Key, false)) + { + if (item.Value != null) + { + this.Context.MappingTables.Add(EntityInfo.EntityName, item.Key); + this.Context.CodeFirst.InitTables(); + } + } } } }