How can I access metadata (dataannotations attributes) in my asp.net mvc model class from a T4 scaffolding template?
I’m trying to read the ScaffoldColumn attribute in the T4 template so it should know if must render some columns in the index view
Thanks
From within a T4 template you can access attributes from your model using reflection. If you take a look at the existing ASP.NET MVC 3 T4 templates you will see an example:
The basic code involved is shown below: