diff --git a/Src/Asp.NetCore2/SqlSugar/Abstract/InsertableProvider/InsertableProvider.cs b/Src/Asp.NetCore2/SqlSugar/Abstract/InsertableProvider/InsertableProvider.cs index 811f2a9f3..8ade970de 100644 --- a/Src/Asp.NetCore2/SqlSugar/Abstract/InsertableProvider/InsertableProvider.cs +++ b/Src/Asp.NetCore2/SqlSugar/Abstract/InsertableProvider/InsertableProvider.cs @@ -243,11 +243,16 @@ namespace SqlSugar var snowColumn = this.EntityInfo.Columns.FirstOrDefault(it => it.IsPrimarykey && it.UnderType == UtilConstants.LongType); if (snowColumn!=null) { - var id = this.ExecuteReturnSnowflakeId(); + ; if (Convert.ToInt64(snowColumn.PropertyInfo.GetValue(result)) == 0) { + var id = this.ExecuteReturnSnowflakeId(); snowColumn.PropertyInfo.SetValue(result, id); } + else + { + ExecuteCommand(); + } return true; } else @@ -311,11 +316,16 @@ namespace SqlSugar var snowColumn = this.EntityInfo.Columns.FirstOrDefault(it => it.IsPrimarykey&& it.UnderType == UtilConstants.LongType); if (snowColumn != null) { - var id =await this.ExecuteReturnSnowflakeIdAsync(); + if (Convert.ToInt64(snowColumn.PropertyInfo.GetValue(result)) == 0) { + var id = await this.ExecuteReturnSnowflakeIdAsync(); snowColumn.PropertyInfo.SetValue(result, id); } + else + { + await this.ExecuteCommandAsync(); + } return true; } else