ASP.NET Error - The Entry ‘DefaultConnection’ Has Already Been Added. (

Recently, we were facing this error while deploying the asp.net solution into the server (IIS) as a separate application (Sub Domain) in a main web application.
 

Scenario

 
I created a website (say site mymainsite) in window server IIS under a port and then added an another application ( plugin ) under a root-site (mymainsite ) as shown,
 
ASP.NET Error: The entry ‘DefaultConnection’ has already been added. (
 
After deploying the solution, when I opened the site, I got this error. Oops!!!
 
“The entry ‘DefaultConnection’ has already been added. (C:..\web.config line ..)”
 
With some research, I found that it was conflicting with the parent site connection provider. There was a same connection name (DefaultConection) in the parent site.
 
If you have another project using the same connection string name you will receive this error because that connection string has already been added to the collection.
 
Solution
 
We can fix this by updating the web.config file.
 
<remove name="DefaultConnection" />
 
Add the above tag with connection string name just above the connection key.
 
Alternatively, you can clear all connection string adding below tag.
 
<clear />
 
Cheers!!