While debugging an ASP.Net MVC application running under IIS Express, I get the following error when attempting to use the membership provider:
Cannot open database "MyDB" requested by the login. The login failed.
Login failed for user 'MY-PC\MyName'.
I attempted to troubleshoot using the steps outlined in
https://stackoverflow.com/a/2577854/141172
SELECT SUSER_ID('MY-PC\MyName')
returns an ID.
SELECT USER_ID('MY-PC\MyName')
returns NULL
CREATE USER [MY-PC\MyName] FROM LOGIN [MY-PC\MyName]
returns the error message
The login already has an account under a different user name.
Indeed, there is a login account, automatically created when I created the database, called
dbo
which maps to MY-PC\MyName.
My connection string is
Data Source=.\SQLEXPRESS;Initial Catalog=MyDB;Persist Security Info=True;Integrated Security=SSPI;
Running in a production environment I would know how to create appropriate users and logons. I'm stuck on how to resolve the fact that IIS Express is using my Windows account name to try and log into MyDB when that Windows account is already associated with dbo.