2

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.

Abanoub Makram
  • 463
  • 2
  • 13
KOD459
  • 77
  • 1
  • 11
  • http://stackoverflow.com/questions/26248293/sql-network-interfaces-error-50-local-database-runtime-error-occurred-canno – Steve Apr 03 '17 at 09:17
  • As Steve's link says, Start by using SQL Server Management Studio (SSMS) and try connecting with the database. Your c# code should use the same connection string the is shown in SSMS. – jdweng Apr 03 '17 at 09:22
  • @jdweng it was working fine a few days ago, and the other guys have the same connecting string and pointing to the same database. Just stumped at the moment – KOD459 Apr 03 '17 at 09:25
  • The service may of stopped running or the database got corrupted. If everybody is using the same PC then you probably have a credential issue. – jdweng Apr 03 '17 at 09:32
  • We're all on different PC's and the guys are are updating the database no bother to them – KOD459 Apr 03 '17 at 09:34

3 Answers3

8

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.
StefanJM
  • 1,533
  • 13
  • 18
Musab
  • 1,067
  • 12
  • 12
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

enter image description here

Karen Gonzalez
  • 664
  • 9
  • 17
0

Found my error by chance!

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

Got rid of this and everything works!

KOD459
  • 77
  • 1
  • 11