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 7950853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T02:23:33+00:00 2026-06-04T02:23:33+00:00

I have customer data stored in two different databases. The records are kept in

  • 0

I have customer data stored in two different databases. The records are kept in synch and share several fields (e.g. CustomerId, CustomerName, etc). But they also each have their own unique fields…so for example:

Database1 Customer

CustomerId
CustomerName
Field1
Field2

Database2 Customer

CustomerId
CustomerName
DifferentField1
DifferntField2

Each database has its own dbContext that I can independently pull each Customer object from. But what I would really like to have is to use a single dbContext to pull in all the fields into unified Customer object that includes the union of all the fields in both dbs. Is this even possible or advisable?

The rest of my objects in my contexts are wired up automatically using DbSets and specifying a mapping for each entity, like this:

public DbSet<Customer> Customers { get; set; }

and then my mapping class has the typical mapping information:

this.ToTable("Customer");
this.HasKey(t => t.CustomerId);
this.Property(t => t.CustomerName);
this.Property(t => t.Field1);
etc.

So I’m wondering if there is a way to build on this logic with multiple tables/databases and be able to perform not just the selects but all the necessary CRUD operations. Is this even possible to do by overriding the default behavior or not? Or am I off base with how I am approaching the problem?

thanks

  • 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-04T02:23:35+00:00Added an answer on June 4, 2026 at 2:23 am

    You should probably consider abstracting your DB contexts into a repository. So your repository is responsible for marshalling all the data from disparate tiers into a single object for you to use, and each DBContext is then only responsible for it’s specific tier.

    public CustomerRepository
    {
        public Customer GetCustomerFor(int customerId)
        {
            var tier1Obj = Tier1DBContext.Customers.First(x => x.CustomerId == customerId);
            var tier2Obj = Tier2DBContext.Customers.First(x => x.CustomerId == customerId);
    
            // merge them into some new object
    
            return mergedCustomerObject;
        }
    }
    

    There is not going to be getting around that there are two tiers unless you make some kind of linked server call from the DB itself and expose that value in one context (which I wouldnt recommend).

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

Sidebar

Related Questions

I have a client with several applications handling sensitive data stored in eXist—a native
I have a customer who has legacy data stored in Oracle database. Such data
Suppose I have the following types of data: class Customer { String id; //
I have a datatable with data in it (customer addresses). In some instances, column
I have a simple database named customer with a single table data.I want to
I have an Entity Framework data model. Part of the model is a Customer
I have two databases same server same domain and same username and password. I
I have a report that needs to get data from two logical areas of
I have mapped several java classes like Customer, Assessment, Rating, ... to a database
All, I have Core Data implemented in my program to store customer information. Let's

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.