When debugging an ASP.Net MVC application running under IIS Express and trying to use the membership provider, I get the following error:
Cannot open the database "MyDB" requested at login. Login failed.
Login failed for user "MY-PC \ MyName".
I tried to troubleshoot using the steps described in
stack overflow
SELECT SUSER_ID('MY-PC\MyName')
returns identifier.
SELECT USER_ID('MY-PC\MyName')
returns null
CREATE USER [MY-PC\MyName] FROM LOGIN [MY-PC\MyName]
returns an error message
The account already has an account with a different username.
Indeed, there is a login account automatically created when you create a database called
DBO
which is displayed on MY-PC\MyName .
My connection string
Data Source=.\SQLEXPRESS;Initial Catalog=MyDB;Persist Security Info=True;Integrated Security=SSPI;
Running in a production environment, I would know how to create the appropriate users and logins. I am stuck on how to decide that IIS Express uses my Windows account name to try to enter MyDB when this Windows account is already associated with dbo .
authentication sql-server sql-server-2008
Eric J.
source share