---
title: "can we use more than one DbContext classes in a project?"  
description: "can we use more than one DbContext classes in a project?"  
author: "Pawan Shukla"  
published: 2017-11-10  
canonical: https://answers.mindstick.com/qa/30342/can-we-use-more-than-one-dbcontext-classes-in-a-project  
category: "programming"  
tags: [".net programming", "asp.net mvc", "c#"]  
reading_time: 2 minutes  

---

# can we use more than one DbContext classes in a project?

## Answers

### Answer by akriti kashyap

**[DbContext](https://www.mindstick.com/forum/157167/is-making-dbcontext-a-singleton-in-a-web-application-a-good-idea) Classes!**

![can we use more than one DbContext classes in a project?](https://answers.mindstick.com/questionanswer/b7f41fff-b642-40b7-aa81-b890d614e99e/images/9b19d420-184f-4fdf-8477-f9e7c53e1281.png)\

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?](https://answers.mindstick.com/questionanswer/b7f41fff-b642-40b7-aa81-b890d614e99e/images/ec096cab-e71c-434a-9749-977d4926d3c9.png)\

There are different issues you will see when utilizing numerous context types - for [instance](https://yourviews.mindstick.com/view/87886/iskcon-leader-arrest-in-bangladesh-insia-s-instance-on-bail-deniel) shared substance composes and they are going [starting](https://www.mindstick.com/blog/63723/7-ways-to-save-money-when-starting-a-business) 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!


---

Original Source: https://answers.mindstick.com/qa/30342/can-we-use-more-than-one-dbcontext-classes-in-a-project

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
