I have asked this question http://stackoverflow.com/questions/1900415/what-is-the-best-way-to-dynamic-load-connection-strings
But maybe it's better to ask the question a little different.
I have a CRM solution where I have different SQL databases for each company, but I would like to try to only have one IIS site, since the site is always equal except for the SqlConnectionString in the Web.config file. I use LinqToSql and generates the classes automatic using the tools in VS2008. This means that I have the DataClasses wich is automatic generated. I found that this class reads the connection string from the web.config in this line:
public DataClassesDataContext() :
base(global::System.Configuration.ConfigurationManager
.ConnectionStrings["TheConnectionString"].ConnectionString,
mappingSource)
{
OnCreated();
}
The users all logs into the same IIS site wich I want to auhenticate against AD and then redirect them to the CRM site, when I do I would like to dynamic get the right ConnectionString and make the Linq class use that.
Am I on the right track to make this happen? And if so, how do I achieve to load the connectionstring dynamic for the linq classes, the file wich the code above is found is autogenereated and is deleted everytime I compile.
Any ideas?