Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8343335
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:01:38+00:00 2026-06-09T06:01:38+00:00

I have a project called MyApp.DataAccess which contains several database contexts. This started as

  • 0

I have a project called MyApp.DataAccess which contains several database contexts. This started as one context and has grown to three (all separate databases required for my app). As you can imagine I have Initializer classes for each as well and I’m also now trying to use Migrations. I can see that this will really clutter up my MyApp.DataAccess project.

I also have a project called MyApp.Model which contains model classes which are generally organized in folders per their use in each aforementioned Context.

I’m struggling with how best to organize multiple DbContexts and Model classes.

My instinct tells me option 1 but what is the best practice?

  1. Create a MyApp.DataAccess.[ContextName] project for each DbContext which contains the DbContext, migrations, and relevant Model classes. Ultimately I’ll still need a MyApp.Model project to represent non-database Model classes.

  2. Create a MyApp.DataAccess.[ContextName] project for each DbContext which contains ONLY the DbContext and Migrations; continue to use the MyApp.Model for ALL model classes (organized in folders and sub-namespaces).

  3. Do nothing — a single MyApp.DataAccess with multiple DbContexts, multiple migrations, etc.; a single MyApp.Model with Models for multiple databases organized by folder.

What is the best practice / ideal approach?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T06:01:40+00:00Added an answer on June 9, 2026 at 6:01 am

    Your question should start with “why should I have different DbContexts”. In most cases different contexts mean different data models, different – unrelated – responsibilities, and thus should be as well separated as that’s possible. Which means that different assemblies are go.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a project called Data which is a data layer. In this project,
We have a project with 3 subprojects one of which is called bldfiles. Each
In my project I have one app which have its own urls.py like this
I use LINQ-SQL as my DAL, I then have a project called DB which
In my domain I have something called Project which basically holds a lot of
I have an ASP.NET web application project which references another project called ModusCore (or
say that i have a project which lies in a folder called 'bin', and
Let's say I have a model class called Project, but instead of this: class
in the tomcat6 server I have a project that contains a servlet, I called
I'm developing an Android project which currently has 4 packages: com.myapp.app.activities com.myapp.app.db com.myapp.app.ws com.myapp.app.utils

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.