0

Today I found I was no longer able to debug tests involving EF Core. Each such test runs using LocalDB, and starts with a call to a function that calls this code:

db.Database.EnsureDeleted();
db.Database.EnsureCreated();

And before I continue, here's my connection string: @"Server=(localdb)\MSSQLLocalDB;Integrated Security=true;Database=TESTING"

This has always served its purpose of preparing a fresh database called TESTING for each test. But now, I get the following error: Cannot open database "TESTING" requested by the login. The login failed. Login failed for user 'xx\yy'.

Okay. That brought me to Cannot connect to (LocalDB)\MSSQLLocalDB -> Login failed for user 'User-PC\User', which I've actually referred to when solving a different issue in the past. But this time, no changes.

I tried pushing my code and running the tests in Azure Pipelines. It worked. I tried locally running all tests. It also worked. I tried running a single, individual test by using the "run" button instead of the "debug" button in Visual Studio. Perplexingly, that also worked. I rolled back to a commit for a previous version that I know was working at one point, and the behavior is the same as it is now.

So... any ideas?? Seems like it's unrelated to my code and may be either a Visual Studio or LocalDB issue but I'm not sure where to start with either of those.

LocalDB 2019 and Visual Studio 2022 by the way.

1 Answers1

0

I ended up repairing my VS installation (which I believe includes reinstalling LocalDB with the data workload?) and everything seems to be working properly now. Still not sure what happened, but I'm glad it's working.

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 14 '22 at 16:49