I use the “real” IIS 7.5 server in the development phase. The site points to the web project folder which contains WebProjectDir\App_Data\database.mdf.
The site runs under ApplicationPoolIdentity as follows:

When I run the application I get the following errors:
Failed to generate a user instance of SQL Server due to failure in retrieving the user's local application data path. Please make sure the user has a local user profile on the computer. The connection will be closed.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Failed to generate a user instance of SQL Server due to failure in retrieving the user's local application data path. Please make sure the user has a local user profile on the computer. The connection will be closed.
Source Error:
Line 14: public ActionResult Index()
Line 15: {
Line 16: return View(db.Genres.ToList());
Line 17: }
Line 18:
Source File: G:\MvcMusicStore\Controllers\StoreController.cs Line: 16
I can remove these errors by setting the application to run under NetworkService. However, I want to use ApplicationPoolIdentiy if it is possible with any adjustment. How to do this?
@Dave, I found the solution yesterday.
Setting
Load User ProfiletoTruewill make theApplicationPoolIdentityable to attach the database.