My Microsoft Ignite 2019 notes, Donovan Brown: Empowering every developer to innovate with Microsoft Azure

Issue with SQL Server 2008 connection from Visual Studio

If you are trying to connect from Visual Studio to your .mdf database file and have an error like this:

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.

First of all you need to check user permissions on the file and SQL Server data folder. Otherwise you can just turn off the User Instance creation in connection string. To fix the issue that way:

  1. Check if you do not have any data in and remove C:\Users[username]\AppData\Local\Microsoft\Microsoft SQL Server Data\SQLEXPRESS folder
  2. Restart SQL Server service and Visual Studio
  3. Optionally add or set User Instance = False in connection string to the database

Similar issue discussion on Stackoverflow