Atomic Increment with Entity Framework
I have a MySQL Server which I access using Entity Framework 4.0. In the database I have a table called Works into which some counts. I develop web site with Asp.net. This table acccesable one more user same time. And this situation causes wrong incerement problem. My code like that: dbEntities myEntity = new dbEntities(); var currentWork = myEntity.works.Where(xXx => xXx.RID == 208).FirstOrDefault(); Console.WriteLine("Access work"); if (currentWork != null) { Console.WriteLine("Access is not null"); currentWork.WordCount += 5;//Default WordCount is 0 Console.WriteLine("Count changed");