It seems that to skip a member to come on a View you can set ScaffoldColumn attribute to false in your model
[ScaffoldColumn(false)]
public object Id { get; set; }
but here i see that Id is of object type. Is this the only way? I tried with
[ScaffoldColumn(false)]
public int Id { get; set; }
but it didn't work. How can i prevent scaffolding on a primitive type e.g. int,long etc.
Edit
I have define my model as
public class Department
{
[ScaffoldColumn(false)]
public int Id { get; set; }
[Required(ErrorMessage="Name is required")]
[StringLength(25)]
[DisplayName("Name")]
public string Name { get; set; }
public bool Active { get; set; }
}
I have a controller having action Create
. When i right click on create action and select add view and create a strongly type view with this model it creates a view but also adds a textbox for Id
<%: Html.TextBoxFor(model => model.Id)%>
which i suppose it shouldn't have