Is there an attribute that I can use with ASP.NET MVC 3 to prevent model fields from automatically showing up in my view? What I mean by this is that I have classes like the following:
public class EntityBase
{
public int ID { get; set; }
//more fields...
}
public class TestEntity : EntityBase
{
public string TestEntityName { get; set; }
//more fields...
}
I know about all of the attributes in System.ComponentModel and System.ComponentModel.DataAnnotations to enforce validation – Required, StringLength, etc. – but is there one I can use that will prevent certain fields from showing up in the view when I create it from Visual Studio? All of my project’s model classes inherit from EntityBase, but I don’t want any of EntityBase‘s fields to be visible on the view. I’m using Razor as my ViewEngine, in case it matters.
TIA,
Benjy
Use ScaffoldColumn: