You can access the application properties and populate an EntityConnectionStringBuilder and access the ConnectionString property or you can instantiate an EntityManager and use this useful extension method I wrote.
public static class EntityManagerFns { public static string GetConnectionString(this EntityManager entityManager, string keyName) { var resolver = entityManager.DataSourceResolver.ProbedKeyResolver; var key = (ClientEdmKey)resolver.GetKey(keyName, string.Empty, true); return key.ConnectionString; } }
|
You can then call Manager.GetConnectionString("WhateverEntities");
We use CodeFirst exclusively now, so I can't remember if the connection string returned will be an EF string or the raw SQL string.