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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T02:37:01+00:00 2026-05-11T02:37:01+00:00

I switched my DAL from using LINQ over to Entity Framework. Because my application

  • 0

I switched my DAL from using LINQ over to Entity Framework. Because my application connects to different databases depending on the current user, I need to dynamically create the DataContext at run time and pass in the appropriate connection string. However, when I tried to programatically create an Entity Framework connection using my old connection string, the connection failed. It complained that it didn’t recognize the key in the connection string, ‘server’ to be exact.

I found out that I needed to do this in order to get the Entity Framework connection to work:

EntityConnectionStringBuilder entityBuilder = new EntityConnectionStringBuilder(); entityBuilder.Provider = 'System.Data.SqlClient'; entityBuilder.ProviderConnectionString = clientConnectionString; entityBuilder.Metadata = 'res://*/xxxxxxxxxx.csdl...'; Entities entities = new Entities(entityBuilder.ToString()); 

Why is this?
What is the Metadata property for?
Is it going to be a problem that its always the same for multiple different connections?
What should it be?
Is there any way around this?

Thanks in advance!

Update 1: Thanks for the update Randolpho, but…
The whole reason I’m having this issue, is that I can’t store the connection strings in a configuration file. The connection string is dynamically determined at runtime by which user is connecting.

Here is my exact scenario:
If user A is connecting, the app pulls data from database A. If user B is connecting, the app pulls data from database B.
The connection strings are stored in a main database, and the number is potentially limitless. Every time I add a user, I don’t want to have to go into the web.config, not to mention the fact that it would eventually get HUGE!

  • 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. 2026-05-11T02:37:02+00:00Added an answer on May 11, 2026 at 2:37 am

    You will find these links very informative:

    http://msdn.microsoft.com/en-us/library/system.data.entityclient.entityconnection.connectionstring.aspx

    http://weblogs.asp.net/pgielens/archive/2006/08/21/ADO.NET-Entity-Framework-Metadata.aspx

    Bottom line? Entity Framework needs the metadata to build your entity mappings.

    Additionally, you should consider moving your connection information out to your configuration file rather than build it in code. The first link will show you how to do that.

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

Sidebar

Ask A Question

Stats

  • Questions 68k
  • Answers 68k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer I haven't tried digital-metaphors but I have used FastReports for… May 11, 2026 at 12:15 pm
  • added an answer Here's an article I found very very helpful in building… May 11, 2026 at 12:15 pm
  • added an answer Both array_push and the method you described will work. $cart… May 11, 2026 at 12:15 pm

Related Questions

I switched my DAL from using LINQ over to Entity Framework. Because my application
I recently switched my hosting provider and due to the time zone that the
I've recently switched to Linux on my work machine and, new to the Linux
I have gradually abandonned my offline emailer and switched to an online one, but
About 2 years ago I dropped windows from my home PC and switched 100%
I switched to the dvorak keyboard layout about a year ago. I now use
I've switched over to a Mac recently and, although things have been going quite
I've switched computers a few times recently, and somewhere along the way I lost
I recently switched over to a MacBook Pro so I'm still really new at
I just switched two projects over to fogbugz and so far I like it

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.