tags:

views:

42

answers:

1

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?

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
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.