An attempt to attach an auto-named database for file c:\.....\App_Data\aspnetdb.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
The solution for which is as follows:
we have to add following few lines to the web.config file as below:
"User Instance=True;"
Once I added this option to the Connection String everything works fine. So the new connectionstrings look like this.
<connectionstrings>
<remove name="LocalSqlServer">
<add name="LocalSqlServer" providername="System.Data.SqlClient" connectionstring="Data Source=.\SQLEXPRESS;AttachDbFilename=DataDirectory\ASPNETDB.MDF;user instance=true;Integrated Security=True;Initial Catalog=ASPNETDB;">
</connectionstrings>
I hope this helps the visitors.