title: Entity Framework - connection properties from user
body: <p>I'm creating application, that will be able to connect to any database which user wishes. I'm trying to connect, but I'm always getting exception about connection string. My code looks like:</p>
  
  <pre><code>public string GetConnectionString(string userName, string password, string database, string server)
  {
      return string.Format(
                  @"metadata=res://*/Data.Database.csdl|res://*/Data.Database.ssdl|res://*/Data.Database.msl;provider=System.Data.SqlClient;provider connection string=&amp;quot;data source={0};initial catalog={1};persist security info=True;user id={2};password={3};multipleactiveresultsets=True;App=EntityFramework&amp;quot;",
                  server,
                  database,
                  userName,
                  password);
      }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>DatabaseContext context = new DatabaseContext(GetConnectionString(UserName, Password, DatabaseName, ServerName));
  </code></pre>
  
  <p>What is wrong with my connection string? I just copied it from app.config file.</p>