Question

I've spent the last 5 hours attempting to load the .mdf database I have set up on my local development machine on my Windows Server 2012 w/ IIS 8 server to no avail.

Note: I'm currently trying to get this to run on LocalDB, but if I could get it running on my SQLEXPRESS instance that'd be just fine as well (might be prefered if it is simpler).

My current error: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that 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. )

The Website: .net 4.5, x86, using SimpleMembership

I've copied over my *.mdf file from my dev project to the App_Data folder on the server. If I delete the files here, they ARE created but then get a different error.

applicationHost.config:

<add name="Dashboard" enable32BitAppOnWin64="true" managedRuntimeVersion="v4.0" managedPipelineMode="Integrated">
    <processModel identityType="ApplicationPoolIdentity" loadUserProfile="true" setProfileEnvironment="true" />
</add>

Web.config:

<connectionStrings>
    <add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-Dashboard-20131112173402;Integrated Security=true;AttachDBFilename=|DataDirectory|\aspnet-Dashboard-20131112173402.mdf" providerName="System.Data.SqlClient" />
</connectionStrings>

Global.asax:

if (!WebSecurity.Initialized)
{
    WebSecurity.InitializeDatabaseConnection("DefaultConnection", "UserProfile", "UserId", "UserName", true);
}

IIS Application Pool Settings:

Name: Dashboard    
.NET Framework Version: v4.0
Enable 32-Bit Application: True
Identity: ApplicationPoolIdentity
Load User Profile: True

Published Website Directory Permissions:

Dashboard: Full Control

Server:

  • .\SQlExpress is installed and running
  • Microsoft SQL Server 2012 Express LocalDB is installed and running

What am I missing?

Was it helpful?

Solution

The problem was that the .mdf file was being copied while it was already attached to a LocalDB instance running on my dev machine.

Stopping my local IISExpress and then copying the database fixed the problem.

I also had some Anti Forgery Token errors that were solved by generating machine keys and putting them in my web.config. The answer for this problem can be found here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top