I have an ASP.NET MVC application and I cannot connect to the local SQL Server database that is hosted on my machine.
I get the following error:
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: 50 - Local Database Runtime error occurred. Cannot create an automatic instance. See the Windows Application event log for error details. )
I have recently installed SQL Server Express on top of the original SQL Server install; since this has happened, the application can now never get connected to the database. My app is running on the local IIS and under Administrator when I debug through Visual Studio.
Things I have tried:
- I have tried deleting the local databases in the Microsoft folders and re-creating them
- I have tried running the "sqllocaldb start" command and it has started
- I have tried stopping the SQL services and restarting them
- I have tried running the application pool under a user with access to the DB
- I have tested the connection into the application by creating a datamodel, which it can do
- I have tried applying the Everyone group with full control to the instances folder
- I have tried giving public access to the database table
- I have tried deleting and re-creating the database
I am getting the following errors in Computer Management under SQLLocalDB15.0:
The specified resource language ID cannot be found in the image file.
Cannot get a local application data path. Most probably a user profile is not loaded. If LocalDB is executed under IIS, make sure that profile loading is enabled for the current user.
My Connection string is as follows:
<add name="Entities" connectionString="metadata=res://*/Models.DataModel.csdl|res://*/Models.DataModel.ssdl|res://*/Models.DataModel.msl;provider=System.Data.SqlClient;provider connection string="data source=(localdb)\MSSQLLocalDB;initial catalog=DatabaseName;integrated security=True;persist security info=True;multipleactiveresultsets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
I have the following SQL stuffs installed on my machine, I don't know if they are having an effect here: