c# - Use DBML model but different connection string for same model on different machine -
i hope title isnt confusing. here plan do:
say have 10 individual servers located in 10 individual sites across country. have database , front end desktop application.
now have website have same database structure/model 10 servers hold on it. use linq sql set queries change connection string datacontext before executing query.
so have database on webserver serve shell if can create relational queries based on webserver database , send updated information whichever server changing connection string of datacontext.
as mentioned database structure same across individual database , webserver database. using dbml structure have created locally in code update data , change connection string.
make sense? wanting confirm if missing anything
we have situation that. simplified, our web.config
file contains entries like:
<appsettings> <add key="server1_connectionstring" value="data source=myserveraddress;..."/>
then in code, can:
use (var dc = new dbdatacontext(configurationmanager.appsettings[ system.environment.machinename.tolower + "_connectingstring"])) { ....
the code uses different connection string based on machine it's run on.
Comments
Post a Comment