I am trying to use the Compare attribute in MVC 4 to ensure user enters the same password twice during registration. I am using Code First approach. My sample model is as follows.
public class Registration
{
public int RegistrationId { get; set; }
[Required]
[StringLength(16, MinimumLength = 6)]
[Display(Name = "Username")]
[Remote("CheckUserName", "Home", ErrorMessage="Username is taken.")]
public string UserName { get; set; }
[Required]
[StringLength(100)]
[DataType(DataType.Password)]
public string Password { get; set; }
[Compare("Password")]
public string PasswordConfirm { get; set; }
}
The only problem with this is that the database table that gets generated would contain two password fields. Is there a smart way to avoid this problem?