My current connection string that resides in Web.config is this :
<add name="PersonDBContext"
connectionString="Server=111.111.1.11;
Database=MyProgram;
User Id=admin;
Password=12345;
Integrated Security=False"
providerName="System.Data.SqlClient" />
I want to give the same connection string to the program in a dynamic way, this is my attempt :
EntityConnectionStringBuilder csb = new EntityConnectionStringBuilder();
csb.ProviderConnectionString = "Data Source=111.111.1.11;Initial Catalog=MyProgram;User Id=admin;Password=12345;Integrated Security=False";
csb.Provider = "System.Data.SqlClient";
String entityConnStr = csb.ToString();
return entityConnStr;
And this is what I get :
Keyword not supported: 'provider'.
Can you tell me what I am doing wrong? And do I need metadata for Code First connection string? Thanks.
EDIT : I figured that I either shouldn't use EntityConnectionStringBuilder or I should give a Metadata for the EntityConnectionStringBuilder class. Can you tell me one of the ways to how to do this?