title: How to get the DataSource, UserID and Password from an Entity ConnectionString?
body: <p>We have an ASP.NET MVC web application that works with Entity Framework. Everything works quite nicely so far, but now I need to implement a function that allows for importing huge amounts of data into an archive table.</p>
  
  <p>The data I need to import comes as a SQL Server Compact database file which I can upload and process through the web application. My first attempt was to read in the rows and create new objects for each row, which I added to a list of that type. Then I used EF's <code>AddRange()</code> method for adding the rows to the database.</p>
  
  <p>This method did not work because of memory and performance issues, even with small import files. So I googled a bit and decided to go for an <em>SQL bulk insert</em> (and thereby circumventing EF), which was clearly stated as the most performant way.</p>
  
  <p>In my <code>web.config</code>, I have the EF connection string, which also contains the data that is neccessary for accessing the database. As I need to work with an <code>SqlConnection</code>, I do need a working SQLProvider ConnectionString. The EF connection string does not work in that case because of additional entries that the SqlConnection does not work with (leading to errors like "unsupported keyword: metadata" etc).</p>
  
  <p>So I want to build a new SqlConnection connection string with an <code>SqlConnectionStringBuilder</code>. I only need three parameters: UserID, Password and DataSource. All of these are present in the EF connection string.</p>
  
  <p>How can I get them from my existing EF connection? I definitely do not want some ugly parsing/regexing, but I could not figure out how to get these values.</p>