0

I'm building database by using mysql connector with EF6.
Way to handling concurrency updates happens.

  1. Client A updates row

  2. Client B come in updates same row

  3. Client B need to wait Client A commit his updates. Codes:

         using (myEntities db = new myEntities ())
         {
             db.Database.Connection.Open();
             try
             {
                 using (var scope = db .Database.BeginTransaction(System.Data.IsolationLevel.Serializable))
                 {
                     {  
                         var test = db.customer_table.Where(x => x.id == 38).FirstOrDefault();
                         test.bank_holder_name = "CLIENT A";
                         db.SaveChanges();
                         scope.Commit();
                     }
                 }
             }
             catch (Exception ex)
             {
                 throw;
             }
         }
    

While debugging, I purposely pause when Client A doing this SaveChanges() step. But Client B can finish his updates without any wait. Anyone here is experiencing this issue?

P/S: I did a lot reading and trial about Entity Framework concurrency issue, like;
a) Optimistic locking with row_version (Not working perfectly if the timestamp not unique enough to catch concurrency)
b) Transaction Scope (Still the same as result above)

Anyone here have idea to stop concurrency in Entity Framework? Thanks in Advance!

Tsushima
  • 33
  • 4

0 Answers0