I am using code like this, but I get an exception: "The underlying provider failed on open." What is the possible reason for that? I have commented the connection string in the app.config
file.
SqlConnectionStringBuilder sqlConnection = new SqlConnectionStringBuilder();
sqlConnection.DataSource = dataSource;
sqlConnection.InitialCatalog = initialCatalog;
sqlConnection.IntegratedSecurity = true;
EntityConnectionStringBuilder entityConnection = new EntityConnectionStringBuilder();
entityConnection.Provider = "System.Data.SqlClient";
entityConnection.Metadata = "res://*/Restaurant.csdl|res://*/Restaurant.ssdl|res://*/Restaurant.msl";
entityConnection.ProviderConnectionString = sqlConnection.ToString();
using (EntityConnection conn = new EntityConnection(entityConnection.ToString()))
{
conn.Open();
MessageBox.Show("Just testing the connection.");
conn.Close();
}