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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:37:02+00:00 2026-06-09T04:37:02+00:00

If you are using object contex data model (with EDMX file), during its creation

  • 0

If you are using object contex data model (with EDMX file), during its creation you might want to specify the connection string inside your config file.

The connection string is unfortunately not the common connection string as it contains some …things needed for the entity connections. Example with MySql connection:

<add name="MyDbEntities" connectionString="metadata=res://*/Namespace.MyDb.csdl|res://*/Namespace.MyDb.ssdl|res://*/Namespace.MyDb.msl;provider=MySql.Data.MySqlClient;provider connection string=&quot;server=172.17.17.154;User Id=user;password=password;Persist Security Info=True;database=MyDatabase;Convert Zero Datetime=true&quot;" providerName="System.Data.EntityClient" />

The problem I have is that this connection string contains the connection string of the provider in the parameter “provider connection string”.

For a specific reason, I need to create a new MySqlConnection, unrelated to the entity model.
For creating the MySqlConnection, I need to provide it the mysql connection string – which is the provider connection string for the entity model and I know the connection string I need is always the same connection string for the entity model.

But how do I get the provider connection string programmaticaly? I was stuck with browsing the model instance with no success…

The following:

ModelInstance.Connection.ConnectionString

contains something like “name=TestBotEntities”, not even the whole connection string. So I tried:

ConfigurationManager.ConnectionStrings["MyDbEntities"].ConnectionString

but that one contains the whole entity connection string and I just don’t know how to parse it, how to get only the provider connection string from it.

  • 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-09T04:37:03+00:00Added an answer on June 9, 2026 at 4:37 am

    Turns out there are two ways.

    I could parse the entity connection string via the EntityConnectionStringBuilder:

    string entityConnectionString = ConfigurationManager.ConnectionStrings["MyDbEntities"].ConnectionString;
    string providerConnectionString = new EntityConnectionStringBuilder(entityConnectionString).ProviderConnectionString;
    

    …or if I have the specific model instance available, I can get it from here.

    ((System.Data.EntityClient.EntityConnection)ModelInstance.Connection).StoreConnection.ConnectionString;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are using Fluent NHibernate for data object model in the company i work.
I am recrusively evaluating properties via reflection using object.GetType().GetProperty(string propertyName). This is working fine
Following the tutorial on http://msdn.microsoft.com/en-us/data/gg715119 it describes adding an EDMX Entity Data Model to
i need some help with designing iphone's core data object model context. I've started
I'm receiving this fatal error message: Using $this when not in object context. This
I've read that using Object.prototype to attach functions to custom JavaScript objects is more
I'm using object and collection Initializers in the program and thinking how to get
I have a byte[] that i obtained using Object ArrayList<Obj> Can anyone tell me
I'm building a javascript application using object oriented techniques and I'm running into a
I am trying to access member variables of a class without using object. please

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.