I want to save user without email, like this:
var user = new ApplicationUser { UserName = model.Name };
var result = await UserManager.CreateAsync(user);
Actually there is a better way. Alter the validation for just when you need to ignore it and then restore it back when done. (Don't use async in this case because another thread might be need to update(?))
// first create/update the identity!!!
user.PasswordHash = UserManager.PasswordHasher.HashPassword(model.Password); //hash and update directly
// alter
UserManager.UserValidator = new UserValidator(UserManager)
{
AllowOnlyAlphanumericUserNames = false,
RequireUniqueEmail = false
};
var result = UserManager.Update(user);
// restore...
UserManager.UserValidator = new UserValidator(UserManager)
{
AllowOnlyAlphanumericUserNames = false,
RequireUniqueEmail = true
};