Tech Off Thread

2 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

Please confirm these facts about MVC 4

Back to Forum: Tech Off
  • User profile image
    Sathyaish Chakravarthy

    I did MVC 2 two years ago. I am now using MVC 4 and would like to confirm a few things (StackOverflow is down for maintenance just now for about an hour).


    1. In MVC 4, we do not need to create a ModelMetadata class to annotate with data annotations for data validation. We may simply annotate the model classes themselves.

      In other words, if we are using the EDM generator to generate a model and corresponding classes for us, then we may create a new set of partial classes with the same names and use data annotation attributes on those partial classes themselves.

      We do not need to create a new type of model metadata class and decorate *that* class with data annotation/attributes, like here:

    2. For data annotations to work, we need a reference only to System.ComponentModel.DataAnnotations and not to Microsoft.Web.Mvc.DataAnnotations.
    3. We do not need to instantiate the default model binder in the Application_Start event in the Global.asax file.

    Could you please confirm if my understanding is correct?

  • User profile image

    All of those affirmations are correct. The MVC codebase has changed a lot since version 2. All of the model validation is made by using attributes from the System.ComponentModel.DataAnnotations namespace. 

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.