Preventing performance problems with Entity Framework and Unit of Work
Andrew Duncan

Typically this problem can be easily prevented at least in two ways:

  1. The UoW has both a begin and commit method with an internal scope counter —if every service method does a begin and commit, save changes will only be invoked once when your code goes back to the initial method that started the work (my recommendation is to use aspects) — see my ScopedEnabledUnitOfWork;
  2. Using a mediator and commands — keeping the same scope concepts from option 1, you only need to begin before commands execution and commit on successes. For this you normally won’t need aspects since the mediators typically provide a pipeline for interceptions — see my mediator library for details;

Normally this is enough to prevent most performance issues on bulk operations.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.