Contents tagged with T4
-
T4 Metadata and Data Annotations Template
Awhile back I was working on an ASP.NET MVC 3 project that required a lot of “standard” validation to be performed (required fields, validate lengths, some regular expression validation here and there, data type checks, etc.). Due to the number of classes involved I decided to go with the data annotations approach to keep things nice and tidy (some people love this, some people hate it – such is life :-)). As I dug more into the project I realized it was a fairly monumental task to create a metadata class for each of my model classes so I ended up investing one night to create a Visual Studio T4 template that could generate all of the metadata classes automatically based on an Entity Framework 4 model. I published the project up on CodePlex to make it easy for other devs to get to but realized I never blogged about it. Here’s an overview of what the T4 metadata and data annotations template does.