When you create the connection strings in web.config you pass names to them in the name property. For you to choose one in your DbContext
implementation, simply pass the name of the connection as it is in the name property in web.config to the base class constructor. It's like you did, but with the name of the other connections.
EDIT: An example would be the following, you add in web.config the following connection string
<connectionStrings>
<add name="Exemplo" connectionString="ConnectionString" providerName="Provider" />
</connectionStrings>
Since ConnectionString
is your connection string and Provider
your provider, which in this case and SQL Server is System.Data.SqlClient
. Hence in your context, you would do the following
public class ContextoExemplo : DbContext
{
public ContextoExemplo() : base("Exemplo") {}
}
Then this context will sweat the connection string with name
Example you added. Each context would simply have that over there what goes in the name property and EF knows what to use that connection string.