We use Entity Framework 5, but have a requirement to ALSO use a normal database connection from the application for some custom SQL we need to perform.
So, I am creating
Here is a generic way of getting the connection string:
public string GetConnString(T ent)
where T : ObjectContext
{
EntityConnection ec = (EntityConnection)ent.Connection;
SqlConnection sc = (SqlConnection)ec.StoreConnection;
return sc.ConnectionString;
}
Then to use it would be:
MyEntities ent = new MyEntities();
String ConnString = GetConnString(ent);