title: Why does an Entity Framework Connection require a metadata property?
body: <p>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.</p>
  
  <p>I found out that I needed to do this in order to get the Entity Framework connection to work:</p>
  
  <pre><code>EntityConnectionStringBuilder entityBuilder = new EntityConnectionStringBuilder();
  entityBuilder.Provider = "System.Data.SqlClient";
  entityBuilder.ProviderConnectionString = clientConnectionString;
  entityBuilder.Metadata = "res://*/xxxxxxxxxx.csdl...";
  Entities entities = new Entities(entityBuilder.ToString());
  </code></pre>
  
  <p>Why is this?<br>
  What is the Metadata property for?<br>
  Is it going to be a problem that its always the same for multiple different connections?<br>
  What should it be?<br>
  Is there any way around this?  </p>
  
  <p>Thanks in advance!</p>
  
  <p>Update 1:
  Thanks for the update Randolpho, but...<br>
  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.  </p>
  
  <p>Here is my exact scenario:<br>
  If user A is connecting, the app pulls data from database A.  If user B is connecting, the app pulls data from database B.<br>
  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!</p>