diff --git a/Src/Asp.NetCore2/SqlSugar/Realization/Kdbndp/Insertable/KdbndpInserttable.cs b/Src/Asp.NetCore2/SqlSugar/Realization/Kdbndp/Insertable/KdbndpInserttable.cs index c3893c492..5febeede9 100644 --- a/Src/Asp.NetCore2/SqlSugar/Realization/Kdbndp/Insertable/KdbndpInserttable.cs +++ b/Src/Asp.NetCore2/SqlSugar/Realization/Kdbndp/Insertable/KdbndpInserttable.cs @@ -37,7 +37,14 @@ namespace SqlSugar public override KeyValuePair> ToSql() { var result= base.ToSql(); - return new KeyValuePair>(result.Key.Replace("$PrimaryKey", GetPrimaryKeys().FirstOrDefault()), result.Value); + if (GetPrimaryKeys()?.Any() == true) + { + return new KeyValuePair>(result.Key.Replace("$PrimaryKey", GetPrimaryKeys().FirstOrDefault()), result.Value); + } + else + { + return new KeyValuePair>(result.Key.Replace(" returning $PrimaryKey", ""), result.Value); + } } public override long ExecuteReturnBigIdentity()