Lightswitch can't connect to the database on local development (VS 2012)

1.8k views Asked by At

I have LightSwitch installed in VS 2012. I have SQL Server 2012 Express with LocalDB installed on my machine.

I created a new project, add new table, and when I run the project I get the following error:

An error occurred while establishing a connection to SQL Server instance '(LocalDB)\v11.0'.
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. Error occurred during LocalDB instance startup: SQL Server process failed to start.

This is my config in C:\Users\xxx\Documents\Visual Studio 2012\Projects\NightApp\NightApp\NightApp.Server

<add name="_IntrinsicData" 
     connectionString="Data Source=|SqlExpressInstanceName|;AttachDbFilename=|ApplicationDatabasePath|;Integrated Security=True;Connect Timeout=30;MultipleActiveResultSets=True" />
<add name="2aaf8de2-05e2-49ae-aead-766e8c010988" 
     connectionString="Data Source=(localdb)\Projects;Initial Catalog=NightDB;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False" />

I also went through how to change the connectionstrings of a lightswitch application in debug mode but I could not get it done.

BTW, the sql server explorer in vs 2012 is able to connect to the localdb.

Any ideas?

1

There are 1 answers

1
Bandara On

This may due to a bug in sql runtime, re-crating sql instance may fix the issue.

Execute following powershell commands

  1. Delete existing instace: SqlLocalDB d v11.0
  2. Re-create the instace and start: SqlLocalDB c v11.0 -s