Figure 3. connectionStrings in web.config

Writing connection string manually is one of the worst things in software development. That's why I always want them to be generated by any tool but not by me. Some times before I have found a way how to generate a connection string creating an .udl file in Windows (https://markimarta.com/c/how-easily-write-the-text-of-connection-string/). Now I've found a better way.

This method allows to generate connection string and save it to web.config file directly.

So press Alt+Enter or right click on your Project and choose Properties, in the opened windows go to tab "Settings" (Figure 1).

 

Figure 1. Properties of application and Settings

Figure 1. Properties of application and Settings

 

Now you need to fill the new setting. Click on the field in column "Name" and enter the name of variable. In the column "Type" choose "Connection string". In the right side of "Value" column you can see the button with "…". Click on it and Connection Properties window will be opened (Figure 2).

Figure 2. Connection Properties window

Figure 2. Connection Properties window

 

Save changes, press Ctrl+S.

Now when you open Web.config in your project, you will find the new element in connectionStirngs node (Figure 3). So you can rename it of you want and use in your project.

Figure 3. connectionStrings in web.config

Figure 3. connectionStrings in web.config