tmenier / AsyncPoco

A long-"awaited" fully asynchronous PetaPoco fork
Other
127 stars 33 forks source link

Error calling AsyncUpdate against SQL Server database with identity primary keys #56

Open MoxiePoxy opened 5 years ago

MoxiePoxy commented 5 years ago

The UpdateAsync method in version 2.0.1 attempts to write primary key values on update. This causes an exception on SQL Server where the primary keys are identities.

This fix is in the main branch of PetaPoco’s Database class in the ExecuteUpdate method:

// Don't update the primary key, but grab the value if we don't have it
if (string.Compare(i.Key, primaryKeyName, true) == 0)
{
    if (primaryKeyValue == null)
        primaryKeyValue = i.Value.GetValue(poco);

        continue;
}

https://github.com/tmenier/AsyncPoco/blob/02863e6a0387faff4fbb607f0725248b2bc55f13/AsyncPoco/Database.cs#L1305