How to manage dbContext in a multi-user application?

I put together my first line-of-business app using WPF/MVVM/EF6(db-first)/MSSQL and realised that multiple users could not see each others’ changes because I was using one dbcontext and keeping it open.

I’ve read loads of articles about dbcontext and whether to dis/connect and whether to eager/lazy load and they all say ‘it depends’. So my question is – how do I manage my dbcontexts in this common scenario:

The user opens a datagrid and it fetches some a list of employees.
They filter it by EmployeeType.
They edit row1 and save changes.
They select row2 which instantly changes to show an edit that another user made.
They select row1 and a new row appears which another user has added.

Surely this is a common use-case which everyone has done time and time again. I could build this in MSAccess in about 15 minutes.


Trả lời

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *