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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:37:40+00:00 2026-05-20T10:37:40+00:00

I am trying to use the ADO.NET Entity Data Model in a way that

  • 0

I am trying to use the ADO.NET Entity Data Model in a way that I can on the fly change which database I point too. Changing databases may require an entirely new connection string. Some databases are on different servers. So I need the ability to pass my ADO.NET Entity Data Model a custom connection string formated like so ‘server=severaddress;database=database1;User ID=test;Password=test1234;’

Edited: My Entity Class implements ObjectContext. The three constructers I can use is the default, pass in connectionString, pass in an EntityConnection. When ever I use the overload constructers I get errors saying it doesn’t recognize “server” in the connectionstring.

I need to either instantiate my repository with a custom connection string, or be able to set it before use.

  • 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-20T10:37:40+00:00Added an answer on May 20, 2026 at 10:37 am

    ObjectContext accepts entity connection string in its constructor. Entity connection string consists of three parts:

    • Metadata location (location of mapping XMLs produced by EDMX file)
    • Data storage provider
    • Data store connection string (that is what you want to provide)

    You have several ways to achieve what you want. Generally what you need is combine two parts of connection string:

    string format = "metadata=res://*/Model.csdl|res://*/Model.ssdl|res://*/Model.msl;provider=System.Data.SqlClient;provider connection string=\"{0}\"";
    string connectionString = "server=severaddress;database=database1;UserID=test;Password=test1234;"
    
    var context = ModelContext(String.Format(format, connectionString));
    

    The format describes location of metadata from Model.edmx included as resources in assembly and Sql provider. Second part is your connection string.

    Be aware that this will only work if all your databases have same schema and use same provider.

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

Sidebar

Related Questions

While trying to use the entity framework and ado.net data services, I'm hitting a
So, I'm trying to use ADO.NET to stream a file data stored in an
I'm trying to use: // this is a BreakHistory class from the ADO.NET Data
I'm trying to create a function that takes any table from my ADO.NET Data
I’m attempting to use ADO.NET Data Services to update my database. Tables: Person( PK
I am trying to use ADO.Net Codefirst feature of latest Entity Framework 4.0. As
I'm trying to use the Task-Parallel-Library to offload expensive ADO.NET database access from the
I'm using the ADO.Net Entity Framework. To handle input validation I'm trying to use
I'd like ask a question about building applications in .NET that use data from
I'm simply trying to get data from two sql server db tables using ado.net

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.