Add unit of work pattern to fix databasecontext sync problems.