Thread safe
Entity context access
Entify framework is completely thread safe. This means that you can't get the entity context into
inconsistent state by playing around with multiple threads. Entity context is protected in such a
way that only one thread can access it at the time. In most cases this is not a problem since all
the operations are very fast even with multiple entities.
Handling update conflicts
Let's say that you have a person entity in your entity context and you have queried the same entity
twice from the different threads. The first thread changes the name of the person and updates changes
to entity context. Now, the second thread changes the name as well and tries to update it to the context.
What happens? If the update is successful, then the first update is lost which is probably something
that we wouldn't want to happen. Entify solves these kind of conflicts with optimistic online lock
pattern. So in this example, when the second thread tries to save enityt changes, an exception
is thrown. Exception indicates that the entity has changed in the context since it was loaded last time.
|