In her SQL Profiler trace she has this command executed:
exec sp_executesql N'declare @p int
set @p = 0
where ([SalesOrderID] = @0)
select [SalesOrderNumber], [TotalDue]
where @@ROWCOUNT > 0 and [SalesOrderID] = @0',N'@0 int',@0=71774
What's the logic behind the update command, that is not updating any value?
We are having our Entity Framework 4 sessions fail, and it seems that these redundant updates are the cause. The undesired updates are forcing our _VERSION timestamp to be incremented and then we are receiving concurrency update errors - even on a
local database with only one user testing. This has us really dismayed and disappointed. Why is this happening?
System.Data.OptimisticConcurrencyException was unhandled by user code
Message=Store update, insert, or delete statement affected an unexpected number of rows (0). Entities may have been modified or deleted since entities were loaded. Refresh ObjectStateManager entries.
at System.Data.Mapping.Update.Internal.UpdateTranslator.ValidateRowsAffected(Int64 rowsAffected, UpdateCommand source)
at System.Data.Mapping.Update.Internal.UpdateTranslator.Update(IEntityStateManager stateManager, IEntityAdapter adapter)
at System.Data.EntityClient.EntityAdapter.Update(IEntityStateManager entityCache)
at System.Data.Objects.ObjectContext.SaveChanges(SaveOptions options)
at PwC.NDF.Data.EntityFramework.EntityFrameworkDAO`2.GetEntityKey(E domain)
at PwC.NDF.Data.EntityFramework.EntityFrameworkDAO`2.GetID(E domain)