diff --git a/MySqlPlus/MySqlPlus.csproj b/MySqlPlus/MySqlPlus.csproj
index c1a3996..957604c 100644
--- a/MySqlPlus/MySqlPlus.csproj
+++ b/MySqlPlus/MySqlPlus.csproj
@@ -7,7 +7,7 @@
MontoyaTech.MySqlPlus
MontoyaTech.MySqlPlus
MontoyaTech.MySqlPlus
- 1.1.6
+ 1.1.7
MontoyaTech
A simple C# library to help work with MySql.
MontoyaTech 2023
@@ -27,7 +27,7 @@
-
+
diff --git a/MySqlPlus/MySqlSession.cs b/MySqlPlus/MySqlSession.cs
index 05c015c..02c91f8 100644
--- a/MySqlPlus/MySqlSession.cs
+++ b/MySqlPlus/MySqlSession.cs
@@ -69,13 +69,16 @@ namespace MontoyaTech.MySqlPlus
this.Connection.ExecuteNonQuery(command);
- //Update the primary key value on the row if we can find it.
+ //Update the primary key value on the row if it auto increments.
if (row.GetMySqlPrimaryKey(out FieldInfo primaryField, out MySqlColumn primaryColumn))
{
- if (Type.GetTypeCode(primaryField.FieldType) == TypeCode.UInt64)
- primaryField.SetValue(row, (ulong)command.LastInsertedId);
- else
- primaryField.SetValue(row, command.LastInsertedId);
+ if (primaryColumn.AutoIncrement)
+ {
+ if (Type.GetTypeCode(primaryField.FieldType) == TypeCode.UInt64)
+ primaryField.SetValue(row, (ulong)command.LastInsertedId);
+ else
+ primaryField.SetValue(row, command.LastInsertedId);
+ }
}
return (ulong)command.LastInsertedId;