Project background
Windows-certified Web application, LocalDB created through Visual Studio 2013 is located in the App_Data directory
Phenomenon
There is no problem with local debugging. After publishing to the server (Windows server 2008R2, IIS7.5), the browser access throws an exception a network-related or instance-specific error occurred while Establi Shing a connection to SQL Server. The server was not found or is not accessible. Verify 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.
Reason
LocalDB is running based on user mode, and IIS uses the service account by default, thus losing access to LocalDB.
Solutions
Open the corresponding Web application pool properties in IIS, set the identity to a specific domain user, and set the value of load user profile to True to restore the program to normal operation
SQL Server Local DB cannot be accessed after publishing to the server side