2

I have a console application which hosts two WebApi applications using OWIN Self Host approach. One of the apps uses EF6 with Code First. When I run the executable from the bin folder and make a request to the WebApi, everything works like it should - if the database is already created it just returns the results, otherwise it creates the db first. But if I start the console app from Visual Studio (with debugging), I receive the following error:

Additional information: Cannot open database "{db name}" requested by the login. The login failed.

Login failed for user 'sa'.

Anyone has any ideas why this happens?

EDIT: Problem is not related to the self hosted apps. I referenced the dbcontext directly in the console app and the same issue happens. I also tried Integrated Security and it still fails with "Login failed for user '{DOMAIN\USERNAME}'."

EDIT 2: I fixed my problem by doing deleting the .suo file. That helped me find these two questions mentioning the same solution:

Login failed for user "xxx" Failed to open the explicitly specified database solution

EF 4.1 code first causes weird (login) runtime errors

Can anyone say the reason why the .suo file causes this?

Community
  • 1
  • 1
Panayot Todorov
  • 397
  • 2
  • 11
  • I didn't delete any *.suo file explicitly but 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. Bloody hell! – RBT Dec 02 '16 at 10:42

0 Answers0