Multiple Connection Strings with MVC 5 Application

So the critical parts of my web config look like this:

<connectionStrings>
    <add name="AppConnection" connectionString="Server=100.100.100.100;Database=AppDB;User Id=user;Password=password;" providerName="System.Data.SqlClient"/>
    <add name="MemberConnection" connectionString="Server=100.100.100.100;Database=aspnetdb;User Id=user;Password=password;" providerName="System.Data.SqlClient"/>
</connectionStrings>

      

and in the membership providers section:

<membership defaultProvider="SqlProvider" userIsOnlineTimeWindow="15">
  <providers>
    <clear />
    <add name="SqlProvider"
      type="System.Web.Security.SqlMembershipProvider"
      connectionStringName="MemberConnection"
      applicationName="Consulate"
      enablePasswordRetrieval="false"
      enablePasswordReset="true"
      requiresQuestionAndAnswer="false"
      requiresUniqueEmail="true"
      passwordFormat="Hashed"
      maxInvalidPasswordAttempts="5"
      minRequiredPasswordLength="6"
      minRequiredNonalphanumericCharacters="0"
      passwordAttemptWindow="10"
      passwordStrengthRegularExpression=""  />
  </providers>
</membership>

      

As written, when I register, it connects to the wrong database.

However, if I change all instances of "MemberConnection" to "DefaultConnection" it works.

Why should it use "Default" as part of the connection string name?

+3


source to share


1 answer


Within IdentityModels.cs, the ApplicationDbContext constructor inherits the gated "DefaultConnection" string.



Changed this for the connection string which correlates with aspnetdb (membership) and it worked.

+2


source







All Articles