When working in a local development environment it becomes tricky maintaining database connection strings. Every developer in the team usually has his or her own SQL instance and hence the connection strings are different. It becomes tedious and error-prone especially when configuration files are checked in with local connection strings by mistake.

 

To resolve this issue, all the development team members can create one common alias for their SQL server instance and use the alias instead of the server instance name in the connections string. This way the connection string remains constant for every developer. The same alias can be used to connect to the database server via SQL Server Management Studio.

 

The SQL Server instance alias can be created or configured by taking the following steps.

1. Open the SQL Server Configuration Manager.
2. Expand the SQL Native Client 11.0 Configuration node.
3.Select the Aliases node. As you can see below there are no aliases created yet so the list on right is empty.

 

vamshi

 

4. Right click on the Aliases node and create a new alias as shown below.

vamshi1

 

5. Specify the alias name, the port number, the protocol (TCP/IP) and the server name. Click OK.

vamshi2

Note: If there are two SQL Native Client Configuration nodes, the alias should be created in both the places with the same name.

 

6. The new alias shows up in the list as shown below.

vamshi3

 

7. Under SQL Server Network Configuration node, click on the Protocols for MSSQLSERVER node and make sure that TCP/IP is enabled.

vamshi4

 

8. Restart the SQL Server Service.

Sample connection string before and after creating Alias name.

vamashi5

 

Note: We have created Alias name is: ApplicationName.

Vamshi
Vamshi
Technical Lead