I am trying to run an IIS-based application (in the form of a movie database) to teach myself how to develop a three-tier architectural program: MVC application, WCF services, SQL Server database. Since I do not have a license key for a full SQL Server, I decided to go with LocalDB and have WCF services that wrap my stored procedures. This is the first time I'm using LocalDB and confusing the problems associated with my v13.0 instance.
My problem:
I cannot, for my life, get my project in VS to connect to an instance of LocalDB. I keep getting the following error:
When connecting to SQL Server, a network-related or specific instance error occurred. The server was not found or was not available. Verify the instance name is correct and configure SQL Server to connect remotely. (provider: SQL network interfaces, error: 50 - an error occurred executing the local database. The specified LocalDB instance does not exist.
My connection string (from Web.config):
<connectionStrings> <add name="MovieDB" connectionString="Data Source=(localdb)\v13.0;Initial Catalog=MovieDB;Integrated Security=True;AttachDbFilename=|DataDirectory|\MovieDB.mdf" /> </connectionStrings>
Using sqlcmd to connect to it and run queries is fine:

Visual Studio SQL Server Object Explorer can only connect perfectly:

The connection string that Visual Studio deleted when it hit the problem string, so I know that the connection string did not work correctly:
"Data Source=(localdb)\\v13.0;Initial Catalog=MovieDB;Integrated Security=True;AttachDbFilename=|DataDirectory|\\MovieDB.mdf"
I tried following this guide ( Part 1 and Part 2 ) and the images are broken at least on 4/18/2016, so I could not fully understand what I should do. I was able to get the error above because I changed the application pool id to LocalSystem:

When the application pool is running under the ApplicationPoolIdentity identifier, I get this error:
When connecting to SQL Server, a network-related or specific instance error occurred. The server was not found or was not available. Verify the instance name is correct and configure SQL Server to connect remotely. (provider: SQL network interfaces, error: 50 - a local database runtime error occurred. Unable to get the local application data path. The user profile is probably not loaded. If LocalDB is running in IIS, make sure that profile loading is enabled for the current user.
I even went so far as to modify the file C: \ windows \ system32 \ inetsrv \ config \ applicationHost.config to force the profile to load. Still nothing.
<applicationPools> <add name="DefaultAppPool" /> <add name="Classic .NET AppPool" managedRuntimeVersion="v2.0" managedPipelineMode="Classic" /> <add name=".NET v2.0 Classic" managedRuntimeVersion="v2.0" managedPipelineMode="Classic" /> <add name=".NET v2.0" managedRuntimeVersion="v2.0" /> <add name=".NET v4.5 Classic" managedRuntimeVersion="v4.0" managedPipelineMode="Classic" /> <add name=".NET v4.5" managedRuntimeVersion="v4.0"> <processModel identityType="ApplicationPoolIdentity" loadUserProfile="true" setProfileEnvironment="true" /> </add> <applicationPoolDefaults managedRuntimeVersion="v4.0"> <processModel identityType="ApplicationPoolIdentity" loadUserProfile="true" setProfileEnvironment="false" /> </applicationPoolDefaults> </applicationPools>
My application runs under the .NET 4.5 application pool

My code is:
The page loads and calls this service to get a list of movies in the database:
[ServiceContract] public interface IMovieDBService { // ... [OperationContract] List<Movie> GetMovies(int actorID); // ... } public class MovieDBService : IMovieDBService { // ... public List<Movie> GetMovies(int actorID = 0) { var output = new List<Movie>(); using (var connection = DBTools.GetConnection(MovieDBConnectionName)) // Does not get past here; MovieDBConnection = "MovieDB" { var parameters = new List<SqlParameter> { new SqlParameter("@actorID", actorID) }; using (var reader = connection.ExecuteStoredProcedure("GetMovies", parameters)) { while (reader.Read()) { output.Add(new Movie { ID = reader.GetInt32("ID"), Title = reader.GetString("Title"), Year = reader.GetInt16("Year"), Genre = GetGenre(reader.GetInt32("GenreID")) }); } } } return output; } // ... }
And the problematic method from my DBTools project:
public static SqlConnection GetConnection(string connectionName) { var connection = new SqlConnection(); var connectionString = ConfigurationManager.ConnectionStrings[connectionName]; if (connectionString != null) { connection.ConnectionString = connectionString.ConnectionString; connection.Open();
I can only assume that the problem is with authentication or the fact that the application hosted by IIS is trying to connect to the LocalDB user process, but I tried following the instructions from other questions and was unsuccessful (possibly due to an inability to understand the real problem). I am at a loss ...