Without knowing what your context class looks like, say your DbContext
class, if it was generated and assuming it's partial, you could try to add another partial class part to it with a constructor that takes a named connection string as an argument.
First add a named connection to your app.config/web.config:
<connectionStrings>
...
<add name="MyOtherConnection" connectionString="metadata=res://*/blahblahblah;provider=System.Data.SqlClient;provider connection string="Data Source=ABunchOfOtherStuff;"
providerName="System.Data.EntityClient" />
</connectionStrings>
Then add a matching partial class in another (non-generated) file with a constructor to take a connection string name:
// the class name must match the name of your existing context
public partial class MyContext : DbContext
{
public MyContext(string connectionStringName) : base("name=" + connectionStringName)
{
}
}
Then use your context by passing in the name of the connection string, demonstrated by some useless code:
// ...
using (var context = new MyContext("MyOtherConnection"))
{
var id = 1;
var collection = context.MyEntities.Where(a => a.ID == id).ToList();
}