Skip to main content Skip to footer

Changing Connection Strings in LightSwitch

After one of my recent LightSwitch talks, I was asked if there is a way to change the connection string in the LightSwitch designer. This led to a discussion between myself, Michael Washington and Beth Massi. Unfortunately, in the designer, there is not currently a good way to update the connection string. You will have to add a new data source, remove the old one, and redesign all your screens. Since servers can change names, or databases be relocated, this isn't an ideal situation in the long term. I posted a request on User Voice to enable easy changing of the connection string in the designer (Voting has closed). If all you need to do is change the connection string for your services (from a dev/test to a production environment), there are a couple ways to pull this off. The easiest way to change the connection string from a Test to Production environment is in the Publish Wizard. There is a Other Connections step, where you can update the data source for the web services.

After you publish/deploy, you can edit the web.config as usual, and update the connection string that way.

A tempting place to change the connection strings can be found in the file system by navigating into your project's Server Generated folder. This folder is hidden in both the Logical and File views, and for good reason--the code in this folder is "generated by a tool", and any changes you make manually may be overwritten at some point in the future. It's best to stay out of this folder, and make your changes properly.

MESCIUS inc.

comments powered by Disqus