I tried to decorate the POCO class [Display(Name="First Name")] As it should ...
public int Id { get; set; } [Display(Name = "First Name")] public string FirstName { get; set; } [Display(Name = "Last Name")] public string LastName { get; set; }
And also using the attribute [DisplayName("First Name")] .
Regardless, the default List view (using the Add Controller dialog box) generates a table with property names (for example, "FirstName") as header text without respecting attribute values. Creating a view works fine with the [Display(Name=...)] attribute.
The List.tt T4 template has:
<th> <#= property.AssociationName #> </th>
whereas the Create.tt template has:
<# if (property.IsForeignKey) { #> @Html.LabelFor(model => model.<#= property.Name #>, "<#= property.AssociationName #>") <# } else { #> @Html.LabelFor(model => model.<#= property.Name #>) <# } #>
Is there anything else you can do to make the scaffolding use the Display attribute by default? Or do I need to modify the List.tt T4 template to use something else than <# property.AssociationName #> ?
Of course, I can edit the created view. But I like to โfixโ this in the template itself, so ALL created views will be correct without change.
Thanks in advance for your answers.
source share