I am trying to customise the T4 templates used in MVCScaffolding.
I would like to filter out properties which are have the NotMapped
attribute.
My problem is that the attribute collection seems to be empty. I have tried printing out the attributes like below:
List<ModelProperty> properties = GetModelProperties(Model.ViewDataType, true);
foreach (ModelProperty property in properties) {
if (!property.IsPrimaryKey && !property.IsForeignKey) {
#>
<th>
@Html.LabelFor(x => x.First().<#= property.Name #>)
<!--
<#foreach(var attribute in property.Type.CodeType.Attributes)
{#>
Attribute: <#=attribute.GetType().Name#>
<#}#>
-->
</th>
<#
}
}
#>
I cannot find any information about this which actually works and so far it is a very slow case of trial and error. What is the correct way to get the attributes or to get the template to ignore unmapped attributes?