none
which is the diferrences between DbUpdateConcurrencyException and •_OptimisticConcurrencyException? RRS feed

  • General discussion

  • I am using EF6 and I don't know really the differences between both exceptions.

    I know that OptimisticConcurrencyException is a innter exception of DBUpdateException andDBUpdateConcurrencyException is a main exception.

    In both cases they control the concurrency, so when 0 rows are affected are throw. One reason can be the use of a timestamp for control concurrency or another case can be that I try t update a record that was deleted by another user.

    But I don't know the defferences between both exceptions, when is throw one and when is throw another.

    Thanks so much.

    Thursday, May 1, 2014 9:11 AM

All replies

  • Well if you try to update a record that has been deleted by another user before you can update the record with the primary key you had for the record to be updated, then an exception is going to be thrown.

    Most concurrency checks even without EF is based on a timestamp on the record. If the timestamp being held for the record in memory doesn't match the record just read again from the database for update, then another user has updated the record prior to the update process currently in play has updated the record, and a concurrency exception is thrown.

    That's the difference no matter if EF is being used or not.

    Thursday, May 1, 2014 3:57 PM