A: 

Inside your web.config there will be an entry similar to this:

  <connectionStrings>
    <add name="HelpEntities" connectionString="metadata=res://*/Models.HelpModel.HelpModel.csdl|res://*/Models.HelpModel.HelpModel.ssdl|res://*/Models.HelpModel.HelpModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=(local);Initial Catalog=XXX;Integrated Security=True;MultipleActiveResultSets=True&quot;"
      providerName="System.Data.EntityClient" />
  </connectionStrings>

The above example uses integrated security but it is possible to use username and password instead.

Shiraz Bhaiji
+1  A: 

Well, I did some digging around and duct-taped this solution together:

private static string CreateNewConnectionString(string connectionName, string password)
{
    var config = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~").ConnectionStrings.ConnectionStrings[connectionName];
    var split = config.ConnectionString.Split(Convert.ToChar(";"));
    var sb = new System.Text.StringBuilder();

    for (var i = 0; i <= (split.Length - 1); i++)
    {
        if (split[i].ToLower().Contains("user id"))
        {
            split[i] += ";Password=" + password;
        }

        if (i < (split.Length - 1))
        {
            sb.AppendFormat("{0};", split[i]);
        }
        else
        {
            sb.Append(split[i]);
        }
    }
    return sb.ToString();
}

Granted it is not the prettiest method, but it gets the job done. I pass it a connection string name and a password, and it returns an updated connection string with the password. This is how I implemented it:

_entities = new UploadEntity(CreateNewConnectionString("UploadEntity", "[removed]"));
_entities.AddToUploadSet(uploadFile);
_entities.SaveChanges();
Anders
+1  A: 

Use the connection string builder.

Craig Stuntz
Is that basically what I did below?
Anders
Well, you kind of wrote your own, but yes. :)
Craig Stuntz
Yes, that is what I meant hehe. Good to know there is something built in that can do what I did. I will check it out, thanks for the link!
Anders