I been strugling with this for 2 days now without comming any closer to solution. I have read 20-30 threads alteast and stil can not resolve this.
Please help me out
Make sure that the database is created. I got the same error when I applied the migration to the wrong project in the solution. When I applied the migration to the right project, it created the database and that solved the error.
I am using Entity Framework to repupulate my database, and the users gets overridden each time I generate my database.
Now I run this each time I load a new DBContext:
cnt.Database.ExecuteSqlCommand("EXEC sp_addrolemember 'db_owner', 'NT AUTHORITY\\NETWORK SERVICE'");
I was experiencing a similar error message that I noticed in the Windows Event Viewer that read:
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'. Reason: Failed to open the explicitly specified database. [CLIENT: local machine]
The solution that resolved my problem was:
Here's a screenshot of the above: