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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:57:53+00:00 2026-06-17T08:57:53+00:00

Hi I have 2 data contexts that maps different schemas on a SQL Server

  • 0

Hi I have 2 data contexts that maps different schemas on a SQL Server database, but then I need to create 1 sdf database file (SQL Compact) per schema and use the same data contexts, and I have some entities related like this:

//context 1
class A
{
    int Id
    ...
    ICollection<B> Bs
}

//context 2
class B
{
    int Id
    ...
}

On server it’s easy I just need to specify the table for this relation, but on clients I have this entities splitted on different databases.

So I need a navigation property on 1 entity (A) from context 1 (database_A.sdf) to relate with 1 entity (B) from context 2 (database_B.sdf).

Thanks in advance.

  • 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-17T08:57:54+00:00Added an answer on June 17, 2026 at 8:57 am

    Those classes you are implemented are not Contexts those are Entities. The Context in EF should inherit from ObjectContext or DbContext, In your case I think you have 2 separate Entities in 2 different Database. You can do this to pointing several database

    // Associate with first entity
    public Context1 : ObjectContext
    {
        prop IDbSet<A> ADbSet{ get; set; }
        ...
    }
    
    // Associate with Second entity
    public Context2 : ObjectContext
    {
        prop IDbSet<B> BDbSet{ get; set; }
        ...
    }
    
    public void ChangeDb(string dbName)
    {
        Context1 context = new Context1();
        context.ChangeDatabase(dbName);
    }
    

    Hope this help.

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

Sidebar

Related Questions

I have a LINQ to SQL DataContext that queries four different tables. But I
I have 2 data contexts in my application (different databases) and need to be
Here's the issue: I have 2 data contexts that I would like to do
I have a core data context with objects that have a date stored in
I have related data living on two completely separate databases, and I need information
I have a table of data that I want to grab text from, stick
I have a requirement that only super-admins can modify live data. Currently, if an
I am creating 2 projects that have the same database (it's an MDF database).
I´m writing an android application that receives gps data from a MySQL database, such
I have a class that uses linq to access the database. Some methods call

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.