title: AddToRole() returns "User name can only contain letters or digits" only when users email address contains a dash
body: <p>I'm using Asp.Net Identity 2.0, configured so that the users' email address is also the username, so in IdentityConfig I have set <code>AllowOnlyAlphanumericUserNames = false</code> in the ApplicationUserManager constructor:</p>
  
  <pre><code>public class ApplicationUserManager : UserManager&lt;ApplicationUser&gt;
  {
      public ApplicationUserManager(IUserStore&lt;ApplicationUser&gt; store)
          : base(store)
      {
      }
  
      public static ApplicationUserManager Create(IdentityFactoryOptions&lt;ApplicationUserManager&gt; options, IOwinContext context)
      {
          var manager = new ApplicationUserManager(new UserStore&lt;ApplicationUser&gt;(context.Get&lt;ApplicationDbContext&gt;()));
          // Configure validation logic for usernames
          manager.UserValidator = new UserValidator&lt;ApplicationUser&gt;(manager)
          {
              AllowOnlyAlphanumericUserNames = false,
              RequireUniqueEmail = true
          };
  
          // ... other options removed
      }
  }
  </code></pre>
  
  <p>I'm using this code in a page for staff to search for a user and add a role to the user's account when checking a checkbox in a GridView of all available roles:</p>
  
  <pre><code>//protected UserManager&lt;ApplicationUser&gt; um = new UserManager&lt;ApplicationUser&gt;(new UserStore&lt;ApplicationUser&gt;(new ApplicationDbContext()));
  
  //changed this to call the ApplicationUserManager instead of UserManager to make sure AllowOnlyAlphanumericUserName = false is called, but still no luck
  protected ApplicationUserManager um = new ApplicationUserManager(new UserStore&lt;ApplicationUser&gt;(new ApplicationDbContext()));
  
  protected void cbRole_CheckChanged(object sender, EventArgs e)
  {
      string UserName = lblUsername.Text;
      if (!String.IsNullOrEmpty(UserName))
      {
          CheckBox cb = (CheckBox)sender;
          GridViewRow row = (GridViewRow)cb.NamingContainer;
          string Role = row.Cells[1].Text;
  
          if (cb.Checked)
          {
              var user = um.FindByName(UserName);
              var UserResult = um.AddToRole(user.Id, Role);
  
              if (UserResult.Succeeded)
              {
                 lblRoles.Text = "The &lt;b&gt;" + Role + "&lt;/b&gt; role has been added for " + UserName;
              }
              else
              {
                  foreach (var error in UserResult.Errors)
                          lblRoles.Text += error; //&lt;-- RETURNS ERROR: "User name &lt;email address&gt; is invalid, can only contain letters or digits." If &lt;email address&gt; contains a dash (-).
              }
          }
          else
          {
              um.RemoveFromRole(hfAspUserID.Value, Role);
              lblRoles.Text = "The &lt;b&gt;" + Role + "&lt;/b&gt; role has been removed for " + UserName;
          }
      }
  }
  </code></pre>
  
  <p>It usually works perfectly. However, whenever a user has a dash in their username, for example "users.name@domain-name.com," the AddToRole() function returns the error <code>User name users.name@domain-name.com is invalid, can only contain letters or digits.</code></p>
  
  <p>All accounts are local accounts, it's NOT configured to use external logins such as facebook or Google.</p>
  
  <p>Any help you can offer would be greatly appreciated, as my extensive Google search for this problem has come up with nothing other than tutorials on how to implement email addresses as usernames, which I have already done. </p>