Tuesday, August 9, 2011

Build error related to SQL Express in Microsoft LightSwitch

The following message still shows up sometimes while creating and building Microsoft LightSwitch applications. This has not been rectified in the recently released RTM version as seen in the next paragraph.
Error    1    An error occurred while establishing a connection to SQL Server instance '.\SQLEXPRESS'.
Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection will be closed.    C:\Program Files\MSBuild\Microsoft\VisualStudio\LightSwitch\v1.0\Microsoft.LightSwitch.targets    157    10    BusinessTypeTest

However a work around exists which works very well. Here is the work around as suggested by Steven Hoag in his forum post.

  • Stop SQL Express from Control Panel
  • Close all LightSwitch apps
  • Move to the following location:
C:\Users\jay\AppData\Local\Microsoft\Microsoft SQL Server Data\SQLEXPRESS
  • Delete all the files in the SQLEXPRESS Folder.

However when you come to the step of deleting the files you may still get an error, that the files are being used by the SQL Server (despite the fact that you stopped SQL Express in the Control Panel).

To remove them go to the task master (Ctrl+Alt+Del) and bring up the WindowsTask Master window as shown.


Click End Process.


Click End Process for sqlserver.exe in the next window.

Now you can delete all files in the SQLExpress folder

After this start SQLEXPRESS and the previous application which threw the error should build without this error.

PowerShell Pro Tools is a Visual Studio Community 2017 extension that you can try free

I see there is at least one extension, PowerShell Pro Tools that you can download. You can find it in the Visual Studio Community 2017...