I develop an application using EF5 and I would like to know how to configure different connectionString (for example local and live). I know that all connectionsString are in app.config file:
<connectionStrings>
<add name="MandatsEntitiesLocal" connectionString="metadata=res://*/MandatsModel.csdl|res://*/MandatsModel.ssdl|res://*/MandatsModel.msl;provider=System.Data.SqlClient;provider connection string='data source="localhost";initial catalog="UIVB Tests";user id=sa;password=***;MultipleActiveResultSets=True;App=EntityFramework'" providerName="System.Data.EntityClient" />
<add name="MandatsEntities" connectionString="metadata=res://*/MandatsModel.csdl|res://*/MandatsModel.ssdl|res://*/MandatsModel.msl;provider=System.Data.SqlClient;provider connection string='data source="rmsi.net";initial catalog="UIVB Tests";user id=sa;password=***;MultipleActiveResultSets=True;App=EntityFramework'" providerName="System.Data.EntityClient" />
</connectionStrings>
I also know that I can switch between 2 different connection using DbContext constructor :
Partial Public Class MandatsEntities
Inherits DbContext
Public Sub New()
MyBase.New("name=MandatsEntities")
End Sub
Public Sub New(connectionName As String)
MyBase.New(connectionName)
End Sub
End Class
but I need to modify autogenerated class (and I think it's not recommanded)
So, to summarize if I have 10 contexts and 2 databases, I need to manage 20 connectionString !!! And I need to modify autogenerated class
Is there any method to do that properly? What is the best practice?