Handling Optimistic Concurrency
Of course, the ADO.NET Entity Framework provides the ability to handle optimistic concurrency exceptions. You need to intercept eventual
System.Data.Entity.Infrastructure.DbUpdateConcurrencyException instances. When intercepted, you need to determine what entries were not updated in the database by using the
Entries property of the exception instance and make an appropriate decision. The following code revisits the
UpdateProduct custom method described in the “Updating Entities” subsection, providing the first example:
Sub UpdateProduct() Try Dim check = northwindContext.Products. Single(Function(p) p. ProductName = "Italian spaghetti") ...