Frictionless development: Web.config and connection strings
Join the DZone community and get the full member experience.
Join For Freethis is something that i actually run into a lot at customer sites. they have a lot of friction during development between different connection strings that developers use during development. for example, we may have one developer using:
<add name="ravendb" connectionstring="url=http://localhost:8080" />
while another is using:
<add name="ravendb" connectionstring="url=http://localhost:8191;database=theapp" />
this usually causes a hell of a lot of trouble in most teams (or maybe you have developers that use sql express, and some who installed sql development, etc).
that is friction, and you want to deal with that as soon as possible. the easiest thing to do is actually:
<add name="ayende-pc" connectionstring="url=http://localhost:8080" /> <add name="ayende-laptop" connectionstring="url=http://localhost:8191;database=theapp" />
this works, because the connection string name is now the machine name (system.environment.machinename). that is a great first step, because it means that you can get things done without fighting over the connection string in the web.config.
another alternative is to have a default connection string, and allow to “override” it with the specification of a connection string specific for the machine.
it is a small thing, but it actually helps quite a lot. you can extend this to other settings as well. for apps that have a lot of settings, i usually take them out of the web.config into a default.config file, and the configuration reader is set to look for [machinename].config first, and only then at the default.config file.
Published at DZone with permission of Oren Eini, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Trending
-
Part 3 of My OCP Journey: Practical Tips and Examples
-
Transactional Outbox Patterns Step by Step With Spring and Kotlin
-
What Is Envoy Proxy?
-
Breaking Down the Monolith
Comments