We’ve covered a lot of functionality in this chapter, so let’s look at a couple of examples of how that functionality can be used in an application.
You’ll see how you can use the Change Tracker API to resolve
concurrency conflicts and also to log changes that are made during
A concurrency conflict occurs when you attempt to update a record in the database but another user has updated that same record since you queried for it. By default, Entity Framework will always update the properties that you have modified regardless of whether or not there is a concurrency conflict. However, you can configure your model so that Entity Framework will throw an exception when a concurrency conflict occurs. You do this by specifying that a specific property should be used as a concurrency token.
How to configure your model for optimistic concurrency is covered in detail in Programming Entity Framework, 2e (for EDMX models) and in Programming Entity Framework: Code First (for models defined using Code First).
Framework will check if the value in the corresponding database column
has been updated since the record was bought into memory. A concurrency
exception is thrown if the value in the database has changed.
The BAGA model includes two examples of concurrency tokens. The
SocialSecurityNumber property on
Person is marked with the
ConcurrencyCheck attribute. When updating an ...