Search code examples
.netwindows-8.1sql-server-2014-express

SQL Server 2014 Express : Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance


I have a .net wpf application running on Windows 8 & 8.1 making use of SQL Server 2014 Express.

The following error keeps coming back (usually after a restart):

System.Data.Entity.Core.EntityException: The underlying provider failed on Open. ---> System.Data.SqlClient.SqlException: 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. at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)

I looked at the following similar posts:

System.Data.SqlClient.SqlException: Failed to generate a user instance of SQL Server

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

I have changed the user the services runs under to Local System.

I have written a scripts which stops the SQLExpress2014 service deletes all files under the C:\Documents and Settings\{YOUR_USERNAME}\Local Settings\Application Data\Microsoft\Microsoft SQL Server Data\{SQL_INSTANCE_NAME} folder and then restarts the service.

Running the script fixes the issue temporarily but then it usually start occurring again after a restart requiring the script to be rerun.

The following is my application connection string:

metadata=res://*/Models.###.csdl|res://*/Models.###.ssdl|res://*/Models.###.msl;provider=System.Data.SqlClient;provider connection string="data source=.\SQLEXPRESS2014;AttachDbFilename=|DataDirectory|\###.mdf;Database=###;integrated security=True;multipleactiveresultsets=True;User Instance=True;application name=EntityFramework"

Is there something else I have to do to prevent this error?


Solution

  • After a lot of testing and being unable to resolve the issue I decided to turn off "User Instance" and address the legacy reasons why it was on in the first place.

    This is probably a good move anyway as the user instance feature has been deprecated in favour of LocalDB:

    http://msdn.microsoft.com/en-AU/library/hh510202.aspx

    http://msdn.microsoft.com/en-us/library/ms143684.aspx