Trying to connect to a database but getting network-related or instance-specific error along with error: 52

0

Trying to spin up a .NET project with SQL Server Management Studio but I am getting this error when I try to run a update-database in my Package Manager Console:

Specify the '-Verbose' flag to view the SQL statements being applied to the target database.

System.Data.SqlClient.SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections.

(provider: SQL Network Interfaces, error: 52 - Unable to locate a Local Database Runtime installation. Verify that SQL Server Express is properly installed and that the Local Database Runtime feature is enabled.)

System.ComponentModel.Win32Exception (0x80004005): The system cannot find the file specified

ClientConnectionId:00000000-0000-0000-0000-000000000000 Error Number:2,State:0,Class:20

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 52 - Unable to locate a Local Database Runtime installation. Verify that SQL Server Express is properly installed and that the Local Database Runtime feature is enabled.)"

I am not sure if this error is coming from my connection strings or from Management Studio. Here is my connection string inside web.config:

<connectionStrings>
    <add name="DefaultConnection" 
         connectionString="Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\aspnet-ContactWeb-20201025050320.mdf;Initial Catalog=aspnet-ContactWeb-20201025050320;Integrated Security=True" 
         providerName="System.Data.SqlClient" />
</connectionStrings>
c#
.net
sql-server
entity-framework
ssms
asked on Stack Overflow Oct 25, 2020 by Soccerplayer97 • edited Oct 26, 2020 by marc_s

2 Answers

0
<connectionStrings>
        <add name="DefaultConnection" 
             connectionString=@"Data Source=(LocalDb)\MSSQLLocalDB;
                              |DataDirectory|\aspnet-ContactWeb-20201025050320.mdf;
                              Integrated Security=True;
                              Connect Timeout=30;
                              User Instance=True"
             providerName="System.Data.SqlClient" />
    </connectionStrings>
answered on Stack Overflow Oct 29, 2020 by Chameera
0

I also had this error. In my case, this error was because I downloaded the wrong SQL server Express installer file. I downloaded the 2014 version of the file, and the Windows site gave out several installation files, I chose a file that weighs 256 MB, and I had to download a file that weighs 1.2 GB.

answered on Stack Overflow Oct 30, 2020 by Shut_off

User contributions licensed under CC BY-SA 3.0