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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:14:59+00:00 2026-05-31T18:14:59+00:00

I have a LINQ to SQL DataContext that queries four different tables. But I

  • 0

I have a LINQ to SQL DataContext that queries four different tables. But I need to move one of those tables to another database. Is it possible to have a database and connection string for certain tables and another for another table?

So right now I have something like:

[global::System.Data.Linq.Mapping.DatabaseAttribute(Name="DATABASE1")]
public partial class DataClassesDataContext : System.Data.Linq.DataContext
{
    private static System.Data.Linq.Mapping.MappingSource mappingSource = new AttributeMappingSource();

    public DataClassesDataContext() : base(global::System.Configuration.ConfigurationManager.ConnectionStrings["DATABASE1ConnectionString"].ConnectionString, mappingSource)
    {
        OnCreated();
    }

    public DataClassesDataContext(string connection) : base(connection, mappingSource)
    {
        OnCreated();
    }
}

So right now that handles all four tables. I would like for it to handle the first 3 tables and have another for the last. This possible?

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-05-31T18:15:00+00:00Added an answer on May 31, 2026 at 6:15 pm

    Not directly; the most obvious thing would be to split the data-context into two separate data-context classes (and two dbml setups).

    If you are careful, you could leave “as is”, and just explicitly supply the connection-string to each data-context instance, and just don’t use the wrong bits, however: this is risky. In particular, leaving it intact means you still might have queries that try to join between tables that are now in different databases, which won’t work.

    The data-context here is only designed to work in a single database.

    • 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 represents a parent-child relationship of Products to Prices.
I have a LINQ to SQL datacontext that is wrapped in a static class
I have a LINQ-to-SQL data context in which two tables exist with different names
I have a linq to sql database. Very simplified we have 3 tables, Projects
I have a Linq to SQL query that was working just fine with SQL
I have a LINQ TO SQL Context that I have created that calls a
I have a LINQ to SQL class VoucherRecord based on a simple table. One
I have two different DataContexts (SQL Databases) that have the same data, just with
I have some code where I am using a Linq-To-SQL DataContext to add and
I have a program that is accessing many similar tables using a linq to

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.