I have a need to swap between different DB instances of the same design. Is there a way to repoint the DBML to this different DB. What would be ideal would be to specify in code a different web.config connection string. However one would not want to change the Datacontext names in the codebase. If one was doing this in ADO.NET then one could choose the connection string.
Thanks,
Ed
When you instantiate a DBML the appropriate connection string is retrieved from a configuration file. (
app.configorweb.config). In the case that no setting is found, the initial connection string (which exists as a property on the DBML, and can be viewed through the designer) is used.You will only need to use the connection string constructor if you are using multiple connection strings through a single instance, and need to specify the database to which you should connect.
In your case you simply need to include the appropriate connection string in your executing settings file. The connection string must be named correctly – see the setting which is placed in the project containing the DBML to check the name.