Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8375741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:15:15+00:00 2026-06-09T15:15:15+00:00

MVC 4 Beta project fails to compile after upgrading to .Net 4.5. This happens

  • 0

MVC 4 Beta project fails to compile after upgrading to .Net 4.5.

This happens due to conflict between
System.ComponentModel.DataAnnotations.CompareAttribute and System.Web.Mvc.CompareAttribute

System.ComponentModel.DataAnnotations.CompareAttribute MSDN documentation says:

Provides an attribute that compares two properties.

While System.Web.Mvc.CompareAttribute MSDN documentation says:

Provides an attribute that compares two properties of a model.

What is the difference between the two and when it would be “smarter” to use each of them?

10x.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T15:15:16+00:00Added an answer on June 9, 2026 at 3:15 pm

    So, looking at the MSDN documentation and doing a literal comparison of the two classes, I noticed both classes are derived from System.ComponentModel.DataAnnotations.ValidationAttribute. In fact, the classes are almost exactly the same. The only notable difference is that the MVC version also implements IClientValidatable which adds the following properties:

    • FormatPropertyForClientValidation – (static member) Formats the property for client validation by prepending an asterisk and a dot.
    • GetClientValidationRules – Gets a list of compare-value client validation rules for the property using the specified model metadata and controller context.

    As for which class you should use, if the model will be directly bound to a view, use the MVC version so that you can take advantage of the client-side validation. However, if you’re using ViewModels, you can stick with the ComponentModel class and avoid the unnecessary overhead of the additional properties. Your call!

    • System.Web.Mvc.CompareAttribute

    • System.ComponentModel.DataAnnotations.CompareAttribute

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In ASP.NET MVC 4 Beta, I have an entity with this property: [DisplayFormat(DataFormatString =
OK this is an odd one. I wanted to install ASP.NET MVC 2 Beta
What happened to the TagBuilder class between ASP.NET MVC 3 beta and RC? When
I'm working in an ASP.NET MVC Beta 1 project, and I've noticed that if
After installing WebMatrix 2 Beta on my development machine, an MVC project compiled on
From a brand-new ASP.NET MVC 4 Beta Web Application, I'm re-arranging my folders to
I am attempting to use ASP.NET MVC 4 beta together with JSON.NET. I'm using
I have recently upgraded my ASP.NET MVC application from beta to version 1. And
OK, Microsoft removed strongly typed HTML.ActionLink from the main ASP.NET MVC assembly in beta
I'm building an ASP.NET MVC 2 site with Visual Studio 2010 Beta 2. Out

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.