0

Our web.config has this section:

<connectionStrings configSource="connections.config" />

Our connections.config looks (something) like this:

<connectionStrings>
  <add name="conn" connectionString="Data Source=source;Initial Catalog=db;Trusted_connection=True" />
</connectionStrings>

I think the reason we do this is to make it easier for our clients to change the database configuration. But this means that connections.config is checked into source control, and as a developer, I have to change it every time I am developing, and remember not to check those changes in.

As a result, I would like to use the configSource attribute again in connections.config, something like this:

<connectionStrings configSource="connections.local.config">
  <add name="conn" connectionString="Data Source=source;Initial Catalog=db;Trusted_connection=True" />
</connectionStrings>

But when I do this, I get the error:

Parser Error Message: Unrecognized attribute 'configSource'. Note that attribute names are case-sensitive.

Is it not possible to do this? It seems odd that the configSource attribute would only work in web.config itself.

bornfromanegg
  • 2,826
  • 5
  • 24
  • 40
  • You know you don't *have* to get connection strings from the web.config file. You can store them anywhere you like that meets your security and devops needs. You could create a ConnectionStrings.json file and read them from there for example. – mason Nov 04 '21 at 14:14
  • Yeah, there are probably a lot of different ways I could do this, but as far as I’m concerned, the way I tried should work. I’d like to know why it didn’t. (I need to consider that customers already have these config files in their environments, so I’m trying to find the least impact solution to them.) – bornfromanegg Nov 04 '21 at 14:25

0 Answers0