SQL Network Interfaces Error 50 - Local Database R

2019-09-12 19:41发布

问题:

I have the following error when trying to update my database via the PMC on Visual Studio:

"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."

Collaborating with three other people on the same database and they don't have the same problem. I tried just connecting with my local database but I get the same error, does anyone have a clue how to fix it? Been looking for a solution for a long time.

回答1:

Others should try this, it worked for me.

Go to Tools/Options/Database Tools/click Data connection/Now remove Sql Server Instance Name from Right hand box/click ok.

Then try to add another database: Open Solution Explorer/Right click on project/Add New Item/Select Service-based database/click Add



回答2:

Instance might be corrupted or not updated properly
Try these Commands =>

Delete will remove the Database and all of its tables

C:>sqllocaldb stop MSSQLLocalDB
LocalDB instance "MSSQLLocalDB" stopped.

C:>sqllocaldb delete MSSQLLocalDB
LocalDB instance "MSSQLLocalDB" deleted.

C:>sqllocaldb create MSSQLLocalDB
LocalDB instance "MSSQLLocalDB" created with version 13.0.1601.5.

C:>sqllocaldb start MSSQLLocalDB
LocalDB instance "MSSQLLocalDB" started.


回答3:

Found my error by chance!

  public PhotocopierDBContext()
: base("PhotocopierInformationManagementServicesEntities")
 {
 }

Got rid of this and everything works!