nam February 2016

Login failed for LocalDb

We have two sample ASP.NET MVC web applications installed from internet both using SQL EXPRESS LocalDb. When we open one app in VS2015 we can access the LocalDb in the Server explorer of VS2015. But when we close the first app and open the second app in VS2015 and try to access LocalDb in the server explorer we get the following error: Cannot open database "AspnetSampleVS2015-2-1-alpha1" requested by the login. The login failed. Login failed for user 'myDomain\domainUserName'. In web.config file the connection string for both the app are similar except for the db name. The connection string for the second app is:

<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=AspnetSampleVS2015-2-1-alpha1;Integrated Security=SSPI" providerName="System.Data.SqlClient" />

Moreover, when in solution explorer we open the C:\Users\myUsername folder we can see some LocalDb .mdf and .ldf files but no LocalDb files for the above mentioned second LocalDb that leads us to believe that this LocalDb was not installed at all. But the error (shown above) does not indicate it. This sample was installed through NuGet.

Answers


Rachit Gupta February 2016

I guess that the connection string has to include the name of .mdf file also. That may be the reason that it is not getting created for the second project. Also tell whether you created empty project or started with template. If possible share the connection string of first project also.


Kyle Bachmann March 2016

The connection string has changed for VS2015, try this

(LocalDb)\MSSQLLocalDB

Post Status

Asked in February 2016
Viewed 3,230 times
Voted 14
Answered 2 times

Search




Leave an answer