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

Asked 10-Nov-2017
Viewed 1771 times

1 Answer


1

 DbContext Classes!

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

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.

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

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!


Comment
Thanks Akriti ! - Anonymous User22-Jan-2018

Thank for the answer. - Anonymous User23-Feb-2019