I need to use the appsettings/key for my connection string in a web project, and want to re-use this for my connectionstring in the datacontext designer, but it seems all I can use there is the web.config's connectionStrings, so I have to have my DB location in 2 places in the web.config, how can I force the designer (dbml) to use the appsettings instead?
views:
42answers:
1
+1
Q:
Use appsettings connectionstring instead of connectionStrings in web config for datacontext designer
A:
You can pass the connection string into the datacontext constructor.
So you get it from the location you like and pass it in onstructor.
Malcolm
2010-06-16 15:24:42
Thanks but this is not what I need. I have created a partial class that overrides the OnCreated and sets the connection string at runtime, which is in the separate file and does not get overwritten when the dbml file is regenerated. What I want is for design time, so if a developer changes the appsetting connection string, then it will change the DB that is used by the designer.
2010-06-16 15:51:32