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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T11:35:03+00:00 2026-06-05T11:35:03+00:00

I have 2 databases, each with a corresponding EntityFramework DB Context and I am

  • 0

I have 2 databases, each with a corresponding EntityFramework DB Context and I am using Entity Framework 5, Code-First.

I have tables resembling the following:

Table     : Foo (resides in database 1)
-- Column : Id (is primary key)
-- Column : ParentId (is foreign key into Foo)
-- Column : BarId (is foreign key into Bar)

Table     : FooBar (resides in database 1)
-- Column : Id (is primary key)
-- Column : FooId (is foreign key into Foo)
-- Column : BarId

Table     : Bar (resides in database 2)
-- Column : Id (primary key)

Then, I have entities Foo, FooBar in Database1DbContext and Bar in Database2DbContext.

Foo has navigation properties Parent (of type Foo), Children (of type ICollection<Foo>) and Bar (of type Bar).
FooBar has navigation properties Foo (of type Foo) and Bar (of type Bar).

Now, what I want is to be able to .Include(foo => foo.Bar), such that Bar is loaded up for all the Parent and Children of a Foo as well.

I hope I have not been too confusing.

PS: I know there is going to be an issue setting up the Bar navigation property since it is on a different database. I saw suggestions in some related answers suggesting either views or synonyms. Any answers that also take into account that aspect of my situation will be greatly appreciated.

  • 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-05T11:35:04+00:00Added an answer on June 5, 2026 at 11:35 am

    It is not possible. You cannot make cross context queries or cross context eager / lazy loading. You must load Bar instances yourselves for all required Foo and FooBars.

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

Sidebar

Related Questions

I have 12 databases totaling roughly 1.0TB, each on a different physical server running
I have two databases named: DB_A and DB_B . Each database has one collection
I have a script that connects to multiple databases (Oracle, MySQL and MSSQL), each
I have a database that uses codes. Each code can be anywhere from two
I have a table called routes within my database where each route has an
I have a database table of events. Each event has a category and a
I have a database table, my goal is to read in each of the
I currently create a Repository for each database table and a corresponding data class
Assuming you have the following database table: create table Names ( Id INT IDENTITY
I have a table in database which has following structure(data) : +--------------------------+ Organization +--------------------------+

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.