title: Get connection string from Entity Framework web.config
body: <p>I have EF connection string in my web.config as shown below</p>
  
  <pre><code>  &lt;connectionStrings&gt;    
      &lt;add name="Entities" connectionString="metadata=res://*/Model.csdl|res://*/Model.ssdl|res://*/Model.msl;provider=System.Data.SqlClient;provider connection string=&amp;quot;Data Source=Source;Initial Catalog=Pricing;Integrated Security=False;UID=User;Pwd=password;MultipleActiveResultSets=True&amp;quot;" providerName="System.Data.EntityClient"/&gt;   
    &lt;/connectionStrings&gt;
  </code></pre>
  
  <p>and in my code I am doing this to get just the connection string which I am using for some other controls</p>
  
  <pre><code>SqlDataSource1.ConnectionString = ((System.Data.Entity.Core.EntityClient.EntityConnection)Entities.Current.Connection).StoreConnection.ConnectionString;
  </code></pre>
  
  <p>The issue I am facing is that I am getting the connection string but for some reason it does not have the password in it</p>
  
  <pre><code>Data Source=Source;Initial Catalog=Pricing;Integrated Security=False;UID=User;MultipleActiveResultSets=True
  </code></pre>
  
  <p>and so my connections are failing. Can someone please tell me what I am doing wrong here. I just need the below part</p>
  
  <pre><code>Data Source=Source;Initial Catalog=Pricing;Integrated Security=False;UID=User;Pwd=password;MultipleActiveResultSets=True
  </code></pre>
  
  <p>Thanks</p>
  
  <p>Edit : So looks like that the password is hidden by design 
  <a href="https://social.msdn.microsoft.com/Forums/en-US/5a5730be-c93e-4da5-a614-7ed629f06f51/why-would-password-of-connectionstring-be-filtered-after-instantiating-any-object-in-entity?forum=adodotnetentityframework" rel="nofollow noreferrer">https://social.msdn.microsoft.com/Forums/en-US/5a5730be-c93e-4da5-a614-7ed629f06f51/why-would-password-of-connectionstring-be-filtered-after-instantiating-any-object-in-entity?forum=adodotnetentityframework</a></p>
  
  <p>Not sure if there is any other way</p>