To construct a sqlconnection object using ado.net, we often need to declare a connectionstring. If we use the entity framework, we also need to define a connectionstring.
Is it possible to get the precise provider connection string that Entity Framework uses?
Assuming the CS is defined as follows on ado.net:
"Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;"
and Entityframework ought to convert their CS format to something similar; is this possible?
I'd want to know whether it's feasible to get the precise provider connectionstring that EF generates.
How can I change a connection string from an entityframework database to a sqlserver connection string?
string entityConnectionString = ... var builder = new EntityConnectionStringBuilder(entityConnectionString); string providerConnectionString = builder.ProviderConnectionString;
I figured it out:
System.Data.EntityClient.EntityConnection c = (System.Data.EntityClient.EntityConnection)EFDBcontext.Connection; String S = c.StoreConnection.ConnectionString;