Visual Studio tries to mount the SQL database when loading the solution. Gives an error: cannot open the database requested at login

I have a Visual Studio solution in which I played with several C # projects related to Entity Framework encoding.

I created several test databases to connect and learn the first and first code of the code. The problem occurs every time I try to open a solution containing these projects, for some strange reason, Visual Studio, or a solution or some project in it tries to connect to these databases. This results in an error since I deleted these databases:

It is not possible to open the Company database requested at login. Entrance failed. Login failed for admin user.

Here is a snapshot of the error message:

enter image description here

I get this error one by one for several databases. But I wonder why VS will try to connect to some database only when loading the solution? If someone else has encountered this situation or found out the reason for this, then it will be really great.

Note The tags in the question I posed relate only to the environment in which I worked. I am trying to understand if my problem is related to these areas.

+7
c # visual-studio visual-studio-2013 entity-framework
source share
1 answer

As stuartd suggested correctly, Server Explorer in Visual Studio is confused. Sending an answer in case it also helps someone else.

I realized that every time I added the Entity Data Model Model Entity Data project for the Entity Framework to the model, as shown below, it added the connection to the Server Explorer window.

enter image description here

The connection corresponded to the database that I selected in the Add ADO.NET Entity Data Model Wizard. I see that there is a red cross against some of them, since I deleted the databases from the instance of SQL Server. Whenever you download a solution, Visual Studio will always try to update the connection of all the databases found in the server browser. In fact, in the case of databases that have a red mark against them (since they are deleted), I am sure that VS should also use retry logic when trying to establish a connection to the database. All this takes and spends time loading the solution.

enter image description here

I deleted those connections marked with a red cross to get rid of the problem. It will be great if someone knows a way to mark connections as inactive, i.e. Connections live in Server Explorer, but VS should not try to connect them every time until I ask him to update or maybe it can update when I span its node.

I also noticed that Visual Studio somehow supports these server explorer connections based on each solution file, maybe in * .suo files. I had to remove these legacy connections after opening every solution that encountered this error related to the problem of connecting to the database when loading into Visual Studio. All the solutions to this problem somehow had at least one project related to the entity infrastructure :)

+4
source share

All Articles