I'm not sure if this is the correct medium for this question, so if it's not please inform me and I will correct.
As an example to illustrate my point, let's say I have 30 .NET applications that are published to 2-3 different web servers. Now, these applications are Intranet based, so I have a C# library that I reference in each of those applications. This library is comprised of methods that I use in each application to find out employee information if necessary. Now, the library has one connection string, but then I have to also reference that same connection string in all of the 30 applications... so if the database changes that the library is referencing, then I have to remember all 30 applications and change each of them individually.
Is there a way to put the connection string in some sort of file (text file, or something), and have each web.config in each of the 30 applications reference that specific file, so if the connection string needs to be changed, I can just change it in the file and then all 30 applications are still okay, or is there not something like that?
UPDATE
Okay, I now know how to reference a text file for connection string purposes.. but, it seems as though I only can do one of two options... either reference my primary connection string and library connection string individually within the web.config like so:
OPTION ONE
<connectionStrings>
<add name="PrimaryCS" // more data />
<add name="LibraryCS" // more data />
</connectionStrings>
This option would require me to change the LibraryCS
connection string in each of the 30 applications if it were ever to be changed (NOT WHAT I WANT)
OPTION TWO
<connectionStrings configSource="MyConfig.config"></connectionStrings>
This option forces me to put both connection strings in the MyConfig.config
file and not just the LibraryCS
file.. so this would result in me having to change the LibraryCS
connection string in every MyConfig.config
file for each of the 30 applications (AGAIN, NOT WHAT I WANT).
WHAT I'M LOOKING FOR
I am looking for a mixture of the two options, but it seems this can't be done, so I'm hoping someone on this medium knows a work-around
<connectionStrings configSource="MyConfig.config">
<add name="PrimaryCS" // more data />
</connectionStrings>
I want the MyConfig.config
file to only hold the LibraryCS
connection string and then have the main PrimaryCS
connection string be separate.. so that if the LibraryCS
connection string were ever needed to be changed, then I only have to do it in one place.