title: ASP.NET MVC Role Providers for MySQL
body: <p>I tried to setup role provider, using this <a href="https://stackoverflow.com/questions/2038993/asp-net-membership-role-providers-for-mysql">article</a>.</p>
  
  <p>It worked partially - provider created some tables in MySQL, but I cannot access it from ASP.NET Configuration Tool. I get following error, while trying to add some roles (Roles->Create or Manage Roles):</p>
  
  <p>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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) at System.Web.Administration.WebAdminPage.CallWebAdminHelperMethod(Boolean isMembership, String methodName, Object[] parameters, Type[] paramTypes) at ASP.security_roles_manageallroles_aspx.BindGrid() at ASP.security_roles_manageallroles_aspx.Page_Load() at System.Web.Util.CalliHelper.ArglessFunctionCaller(IntPtr fp, Object o) at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) at System.Web.UI.Control.OnLoad(EventArgs e) at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)</p>
  
  <p>My Connection string (which works for accesing data with LINQ to MySQL (with dblinq)):</p>
  
  <pre><code>&lt;connectionStrings&gt;
  &lt;add name="ZenToolDB" connectionString="Database=zentool;Data Source=localhost;User Id=root;Password=supersecretpassword" providerName="MySql.Data.MySqlClient" /&gt;
  &lt;/connectionStrings&gt;
  </code></pre>
  
  <p>Any idea, how to make it work? Thanks!</p>
  
  <p>EDIT: Added web.config fragment with providers:</p>
  
  <pre><code>&lt;membership defaultProvider="MySqlMembershipProvider"&gt;
        &lt;providers&gt;
          &lt;clear/&gt;
          &lt;add name="MySqlMembershipProvider"
               type="MySql.Web.Security.MySQLMembershipProvider,
               MySql.Web, Version=6.2.2.0, Culture=neutral,
               PublicKeyToken=c5687fc88969c44d"
               autogenerateschema="true"
               connectionStringName="ZenToolDB"
               enablePasswordRetrieval="false"
               enablePasswordReset="true"
               requiresQuestionAndAnswer="false"
               requiresUniqueEmail="false"
               passwordFormat="Hashed"
               maxInvalidPasswordAttempts="5"
               minRequiredPasswordLength="6"
               minRequiredNonalphanumericCharacters="0"
               passwordAttemptWindow="10"
               passwordStrengthRegularExpression=""
               applicationName="/"/&gt;
        &lt;/providers&gt;
      &lt;/membership&gt;
          &lt;profile&gt;
              &lt;providers&gt;
                  &lt;clear /&gt;
                  &lt;add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="ZenToolDB" applicationName="/" /&gt;
              &lt;/providers&gt;
          &lt;/profile&gt;
          &lt;roleManager enabled="true" defaultProvider="AspNetSqlRoleProvider"&gt;
        &lt;providers&gt;
          &lt;clear /&gt;
          &lt;add connectionStringName="ZenToolDB" applicationName="/" name="AspNetSqlRoleProvider"
              type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /&gt;
          &lt;!--
          &lt;add applicationName="/" name="AspNetWindowsTokenRoleProvider"
              type="System.Web.Security.WindowsTokenRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /&gt;
          --&gt;
        &lt;/providers&gt;
      &lt;/roleManager&gt;
  </code></pre>