T4, or Text Template Transformation Toolkit, is the free code generation engine from Microsoft that is now included in Visual Studio 2008 and and available as a download for Visual Studio 2005 in DSL and GAT toolkits. You can use T4 templates to generate Visual Basic, C#, T-SQL, XML or any other text files.
Here are some articles from Oleg Sych on how the technology can be used...
Text Template Transformation Toolkit
How to create a simple T4 template
How to use T4 to generate .config files
How to use T4 to generate Decorator classes
How to use T4 to generate CRUD stored procedures
T4 as a general-purpose .NET scripting engine
How to generate multiple outputs from single T4 template
Below is a great video by Hilton Giesenow on how it could possibly be used...
Learn about the Text Templating Transformation Toolkit (T4), the code generation engine used as part of Domain Specific Languages and Software Factories projects. With the T4 toolkit now built directly into Visual Studio 2008, you can easily add code generation to your arsenal. Hilton Giesenow demonstrates how