entity-frameworkado.netconnection-stringmembership-provider

How to use EF connection string and ADO.Net connection string in same project


In normal EF connection string which I use is like this:

<add name="NorthwindEntities" 
     connectionString="metadata=res://*/Models.Model1.csdl|res://*/Models.Model1.ssdl|res://*/Models.Model1.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=******;initial catalog=******;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" 
     providerName="System.Data.EntityClient" />

But when I try to add Ado.Net Membership system in the current project, the connection string have to be like this:

<add name="MembershipEntities" 
     connectionString="data source=*****;initial catalog=*****;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework" 
     providerName="System.Data.EntityClient" />

How to handle this situation?

I'm putting this question with solution for anyone else's benefit.


Solution

  • the problem, when add the connection string name here (connectionStringName):

    <membership>
              <providers>
                  <clear/>
                  <add name="AspNetSqlMembershipProvider"
                      type="System.Web.Security.SqlMembershipProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
                      connectionStringName="NorthwindEntities"
                      enablePasswordRetrieval="false"
                      enablePasswordReset="true"
                      requiresQuestionAndAnswer="true"
                      applicationName="/"
                      requiresUniqueEmail="true"
                      passwordFormat="Hashed"
                      maxInvalidPasswordAttempts="5"
                      minRequiredPasswordLength="3"
                      minRequiredNonalphanumericCharacters="0"
                      passwordAttemptWindow="10"
                      passwordStrengthRegularExpression="" />
              </providers>
          </membership>
    

    it brings this error: "Keyword Not Supported: Metadata" to solve this error we need add another connection string in node. and change connectionstring name connectionStringName="MembershipEntities"

    <connectionStrings>
        <add name="NorthwindEntities" connectionString="metadata=res://*/Models.Model1.csdl|res://*/Models.Model1.ssdl|res://*/Models.Model1.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=*****;initial catalog=*****;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
        <add name="MembershipEntities" connectionString="data source=*****;initial catalog=*****;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework" providerName="System.Data.EntityClient" />
      </connectionStrings>