VS2013, first code EF6, MVC, (VB)
I wanted to better understand the pros and cons of using either one context or dividing DbSets into multiple contexts. I read some of the old SO posts on several DbContexts and actually did not find what I was looking for; a comprehensive expression about when and where to use or not to use multiple DbContexts.
In the case of a single user running a program, such as Windows Forms, on their own hardware, it would seem that there is no reason to have several contexts for the convenience of working with code.
In the case of a web application that runs the core business program for several enterprises, it would seem that several DbContexts are needed for security and administration.
But I would like to receive confirmation if I think correctly about this issue. All I can think of is the following, but then I am completely new to this environment:
Pluses of one context:
- Coding has only one context for working with
- (Are there any problems with relationships between contexts?)
- Migrations are easier because there is only one folder and the migration process
- Easier to get a complete diagram built in SSMS or EDMX
- ( Link here to get EDMX diagrams when using code for the first time)
Ends of one context:
- Security can be a problem for multiple web clients in a corporate application
- (Is this a problem for simple websites with simple memberships?)
- Some SO posts seem to indicate that response time is a problem
- (What is the mechanism here?)
That's all I have. I donβt know enough to fully understand both sides, and given the different environments in which we can work, it would seem that the answer to one or more contexts will be different.
I am currently working on a site where members will participate, as well as a downloadable application that will be a personal application on user equipment. In this case, I think that one context for both makes sense, but before I delve into it, I would ask you to discuss this a bit. I believe that others who are a little new to the environment will still have the same questions.
I also note that Microsoft considered it appropriate to add a lot of context features to EF6 and above for EF, so there should clearly be some programming environments that lead to good reasons in order to have multiple contexts.
Thanks for the input.
Best regards, Alan
source share