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.”)]
 

Categories: Uncategorized

8 replies »

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: