3

Im using entity framework code first. When starting the application the application tries to create the database on SQLServer2008R2.

The error message that I'm receiving is:

"Login failed for user "NT instans\Networkservice" Failed to open the explicitly specified database"

After looking more carefully at the problem in the SQLServer log i can see that the error code is: 18456 severity 14 with state 38. Read about it on: http://sql-articles.com/articles/troubleshooting/troubleshooting-login-failed-error-18456/

Do anybody have a idea how to solve this problem?

user473104
  • 301
  • 2
  • 6
  • 17
  • Is your SQL server on the same machine as your program? If different machines, are they in the same domain or a workgroup? If not a domain, do you have identical users on both machines with delegation allowed between them? – Miika L. Apr 04 '12 at 11:58
  • Server is on the same machine as my program – user473104 Apr 04 '12 at 12:01
  • Is it a windows application or in IIS? And also have you set up the SQL Server logins and privileges? – Miika L. Apr 04 '12 at 12:03
  • I faced very similar issue in a web API project in VS 2015 today. I did a clean operation on my C# web API project from solution explorer and it just worked. This is crazy. The same sa credential (configured in web.config file of my project) was working throughout the day and it suddenly stops working out of no where. – RBT Dec 02 '16 at 12:03

3 Answers3

2

I just thought I'd put a solution here that I found after wasting between two programmers too much time: delete the .suo file. I realise the initial question was asked 18 months ago but it might save someone coming across this question in the future.

We tried installing different versions of Visual Studio, deleting localdb instances, logging in as SA, everything.

Sam
  • 946
  • 7
  • 19
  • I faced very similar issue in a web API project in VS 2015 today. I didn't delete any *.suo file explicitly as I couldn't see any. It seems they aren't having any *.suo file anymore. Instead, I did a clean operation on my C# web API project from solution explorer and it just worked. This is crazy. The same sa credential (configured in web.config file of my project) was working throughout the day and it suddenly stops working out of no where. – RBT Dec 02 '16 at 12:02
1

I faced very similar issue in a web API project in VS 2015 today. I did a clean operation on my C# web API project from solution explorer and it just worked. This was quite crazy. The same sa credential (configured in web.config file of my project) was working throughout the day and it suddenly stops working out of no where.

Many other posts including this one suggest deleting *.suo files but I believe Visual Studio isn't creating *.suo files any more. I didn't see them at least in my VS 2015 environment.

RBT
  • 24,161
  • 21
  • 159
  • 240
0

I had the same issue today. A lot of things, including cleaning the solution did not help, but deleting the .suo file helped. It is still there, located in the same folder as a solution file, in the hidden subfolder ".vs". Path example: ".vs/solution-name/v16/.suo". Yep, without a name. I deleted the file and phew, it works again.

Lev
  • 811
  • 12
  • 13