MVC ‘Compare’ – ‘CompareAttribute’ fails after upgrading MVC to .net 4.5

When you upgrade MVC to 4.5 you will get one of the following messages:

1.   ‘CompareAttribute’ is an ambiguous reference between ‘System.ComponentModel.DataAnnotations.CompareAttribute’ and ‘System.Web.Mvc.CompareAttribute’ 
or
2.   The type or namespace name ‘Compare’ could not be found (are you missing a using directive or an assembly reference?) 
Changed: [Compare(“NewPassword”, ErrorMessage = “The new password and confirmation password do not match.”)]
To :[System.Web.Mvc.Compare(“NewPassword”, ErrorMessage = “The new password and confirmation password do not match.”)]
 
Changed:[Compare(“Password”, ErrorMessage = “The password and confirmation password do not match.”)]
To :[System.Web.Mvc.Compare(“Password”, ErrorMessage = “The password and confirmation password do not match.”)]
 
Share on Facebook

Leave a Reply

Your email address will not be published.