I have an ASP.NET project using SQL Server CE 4.0 with Entity Framework 4.0. It works fine on my local computer.
When I move it to the remote server, however, and try to log in to the admin part of the program, I get the following error:
The connection name 'LocalSqlServer' was not found in the applications configuration or the connection string is empty.
It references the following line in the machine.config on the remote server:
Line 237: <membership>
Line 238: <providers>
Line 239: <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="LocalSqlServer" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" applicationName="/" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="7" minRequiredNonalphanumericCharacters="1" passwordAttemptWindow="10" passwordStrengthRegularExpression="" />
Line 240: </providers>
Line 241: </membership>
Now, it's true I don't have an "AspNetSqlMembershipProvider" statement in my web.config that references a connection string called "LocalSqlServer". Instead I have the following:
<membership defaultProvider="DefaultMembershipProvider">
<providers>
<add name="DefaultMembershipProvider" type="System.Web.Providers.DefaultMembershipProvider" connectionStringName="PUGConnection" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="1" passwordAttemptWindow="10" applicationName="/" />
</providers>
</membership>
This actually works locally. The name of the connection string is PUGConnection, not LocalSqlServer.
Why would this work locally, and not remotely? (The remote server is a shared server -- I don't have access to the machine.config.)
If I change the name of the connection string to LocalSqlServer, will it work? And if so, why would it work the other way on my local computer? The machine.config on my local computer looks the same as the one on the remote server, as far as I can tell.
You need to remove it from your config:
<remove name="AspNetSqlMembershipProvider" />
Or, better yet,
<clear />