Preventing race condition of if-exists-update-else-insert in Entity Framework

后端 未结 4 720
天涯浪人
天涯浪人 2020-12-13 00:33

I\'ve been reading other questions on how to implement if-exists-insert-else-update semantics in EF, but either I\'m not understanding how the answers work, or they are in f

4条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-13 01:10

    You can change transaction isolation level using TransactionOptions for TransactionScope to more stricter (I guess, for your case it is RepeatableRead or Serializable), but remember that any locks decrease scalability.

    Does it really matter to provide such level of concurrency control? Will your application be used in same cases in production environment? Here is good post by Udi Dahan about race conditions.

提交回复
热议问题