can we use more than one DbContext classes in a project?

12 votes
95 views
Pawan Shukla asked 10-Nov-2017 in programming by Pawan Shukla

1 Answer

1 votes
akriti kashyap answered 22-Jan-2018 by akriti kashyap

 DbContext Classes!


The answer to your question is, yes definitely it can have several contexts for a primary database. It can be beneficial while the database contains the multiple database schemas and you wanna deal with each of them as a discrete independent zone.

The issue arises when you need to utilize your code first for creating a database that can be done with single context as well. The trick that can be in use is introducing an additional context equipped with all your entities which is been used for the creation of the database. Your genuine application context containing just subsets of your elements must have database initializer set to NULL.


There are different issues you will see when utilizing numerous context types - for instance shared substance composes and they are going starting with one setting then onto the next, and so forth. By and large, it is conceivable, it can make your plan much cleaner and separate diverse utilitarian regions yet it has its expenses is additionally unpredictable. 

Hope this would have been a help to you!

Cheers!

PawanShukla commented 22-Jan-2018 by PawanShukla
Thanks Akriti !
       0