We needed to introduce few new Validation in an old Silverlight app and at the same time; we planned to migrate the app from Silverlight to HTML/JS/CSS so people on mobile devices can also use that app. For the interim release we used System.ComponentModel.DataAnnotations based validations in Silverlight; this enabled us to continue to use the existing entities with data validation rules and most of the server side code “as-is” in the final MVC based release.
If we have the entities with DataAnnotations in place; using Controller’s ModelState.IsValid check and by using Html.Validation*() view helper methods in the view; we can display the validation warnings. In its vanilla form it works only at server side and validation warnings only appear when form is submitted to the server.
One tip here is; MVC comes with its own set of DataAnnotations; one such is “Remote” using which you can validate the field from server side. If you are “reusing” or linking the Entities / Model files in different projects (for instance in Silverlight or some other non MVC web app) you will naturally get errors on using such data annotations. You can make your model class Partial and have a partial class in the MVC project and annotate it with MetadataType and then in the meta data type class use MVC specific data annotations the way you like: