简体   繁体   中英

Cannot open database msqllocaldb

I had mssqllocaldb database in my asp.net mvc project it was working fine. I just imported mdf file from before. It uses windows authentication and because i changed windows it's another user. It gives me this error.

"Cannot open database \\"[mycontext]\\" requested by the login. The login failed.\\r\\nLogin failed for user '[mycurrentuser]'."

Can i do something about it. That database would work without building it again.

问题

My observation would like to point to few things to help you narrow down toward solution.

  • It would be more helpful to narrow down the issue if you could post some code!

  • As you mentioned, you are using windows authentication, the application would run under the ASP.NET account. Try granting that windows user permission to access the database and check again running the application.

  • Try granting the user permission like:

    exec sp_grantlogin 'MachineName\\ASPNET'

  • Also try going through link - it may provide additional direction in your issue. codeproject

One way is to create sql user and use the user to login instead

how to do it can be found here

Create user and assign permission to user in LocalDB in Visual Studio

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM