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

  • Home
  • SEARCH
  • 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 7870707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T01:41:48+00:00 2026-06-03T01:41:48+00:00

I have two databases : – a development database (for testing & dev) –

  • 0

I have two databases :
– a development database (for testing & dev)
– a production database (used by the latest release)

I can successfully interface with my DEV database to Linq using the VS2010 designer (drag and drop of tables that I am interested in and the rest gets generated). This creates me a dev.dbml, and from that, I can instantiate the class deriving from DataContext which gives me beautiful strongly-typed Linq capacity at no cost, which will reflect changes in the database for static code writing.

My program is an .exe which takes a string argument : “dev” or “prod”. Respectively, I’d like to use transparently the “dev” or the “prod” database without losing the strong typing and auto generation benefits of Linq. More importantly, the code has to be database-generic.

  1. Maybe one solution would be to somehow use the settings declared in dev.dbml, but introduce flexibilty on the data source. I understand that this could introduce fails in “prod” (i.e. a table that exists in “dev” doesn’t in “prod”) but I will take care of the replication of “dev” structure to “prod” each time I release.

  2. Another solution I was digging into was writing a wrapper for DataContext, but that would force me to duplicate manually entities from the databases into code… example here : http://andrewtokeley.net/archive/2008/07/06/mocking-linq-to-sql-datacontext.aspx

  3. The other solution I would see would be to have dev.dbml and prod.dbml mapping to their respective databases, but then, how to offer generic code possibilities ?

How would you hack around this ?

  • 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-03T01:41:49+00:00Added an answer on June 3, 2026 at 1:41 am

    LINQ-to-SQL stores its connection string in the application configuration file, which is what’s used by the default constructor. It should provide a constructor that allows you to pass in your own connection string. Just use that to pass in the connection string at runtime to whichever database you want to connect to.

    This does, of course, require that whatever database you connect to has the same tables, columns, etc. as what you designed against.

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

Sidebar

Related Questions

So I have two databases, my development (default) database and my live database. My
I have two SQL Server (2000) databases. Both are used for the same project,
Let's say I have two databases with identical tables, but one database's tables contains
We have two databases, DEV and STAGING. They are for the most part identical.
I have two databases, production and stage. I am getting the error message in
I have two databases called DB1 and DB2 on the same database server. I
I am new to ASP. I have two databases production and developer databases. I
I have two databases that are differently formatted. Each database contains person data such
Quick question about database design. If I have two databases: User_DB and Group_DB, and
So I'm trying to re-select a database, I have two databases, one for VB,

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.