title: ASP.NET Identity - Validation for unique user email address on IdentityUser
body: <p>I am using ASP.NET Identity. I have created my own user class extending IdentityUser.
  I am trying to add validation to the user classes email property to ensure that the users email address is unique.</p>
  
  <p>To do this I have overridden the IdentityUser email property to which I have added a custom ValidationAttribute. As shown below:</p>
  
  <pre><code>[UniqueUserEmail]
  public override string Email
  {
      get { return base.Email; }
      set { base.Email = value; }
  }
  
  public class UniqueUserEmailAttribute : ValidationAttribute
  {
      public override bool IsValid(object value)
      {
          return true;
      }
  }
  </code></pre>
  
  <p>I had planned to use the FindByEmail method on the ASP.NET identity UserManager class to detect any duplicate email addresses.</p>
  
  <p>My issue is how to properly access the UserManager inside my new ValidationAttribute to access the FindByEmail  method. I would also be interested in knowing how others have solved this issue. Adding validation which accesses the database. And in particular how to prevent ASP.NET identity Users with duplicate email addresses in this fashion.</p>
  
  <p>I have been looking at using the remote validation attribute, but it seems a bit heavy weight. I am aware of the ApplicationUserManager UserValidator RequireUniqueEmail, but I would like my model validation to be consistent.</p>
  
  <p>Thanks for your time.</p>