Title kinda says it all.
There appears to be two ways to mark a field as “Please don’t show on the UI” with attributes. One lives in the DataAnnotations namespace, which is where I think it belongs, and the other lives in the MVC-specific namespace System.Web.Mvc, which I think is the wrong place.
It means that for an MVC app, I have to dirty my domain class with the MVC namespace, rather than use the “more generic” ComponentModel.DataAnnotations.
Is there any way to have the MVC framework take notice of the Display() attribute?
Although you should really take note of Paul’s answer re: using ViewModels, a common solution to your problem is to decorate your property with the UIHint attribute which lives in the System.ComponentModel.DataAnnotations namespace.
e.g.
Then add a small view template in Shared\EditorTemplates\Hidden.cshtml like
Where the name of the template matches the string given in UIHint