Hilton Giesenow's Jumbled Mind

the madness that is...

News

This is my little spot in cyberspace where you will find a collection of random (but mostly software-related) thoughts and ideas that are frightening in their shining brilliance (or something like that ;->).
 
Please enjoy your stay and feel free to Contact Me.
 
Microsoft MVP

.Net Links

BlogRoll

Misc. Links

Syndication

T4 Template Items

I've just finished working on a new How Do I video for Visual Studio Extensibility on the topic of T4 Code Generation [Update: the video is now live at How Do I: Create And Use T4 Templates?]. T4, or Text Template Transformation Toolkit, is the free code generation engine from Microsoft that underpins their Domain Specific Languages and Software Factories toolkits. T4 is usually used only to generate code from the models in your DSL, but it's a pretty rich code generation engine in it's own right. I've played a lot over the years with CodeSmith and MyGeneration, so I've been meaning to play with T4 for a while. What's nice about the new version is that it is now built into Visual Studio 2008 - no need for the SDK to get it any more.

If you're interested in finding out more about how T4 works, and to get some great samples, check out Oleg Sych's blog.

One thing I noticed when working with T4 though, is that while the ".tt" file extension works in Visual Studio, there is no item template when you Add .. New Item to your project. I've put 2 Item Templates together to overcome this - one for a simple T4 template and one for an SMO Database-driven template (thinking of replacing the code generator for LINQ To SQL?). You can download the simple T4 C# item template here and the T4 C# Database item template here. To use the templates, simply drop the files into [My Documents]\Visual Studio 2008\Templates\ItemTemplates\

By the way, if you're working with and creating T4 templates, make sure you check out the great free T4 Editor from Clarius Consulting.

Comments

Oleg Sych - » Visual Studio Templates for T4 said:

Pingback from  Oleg Sych  -   » Visual Studio Templates for T4

# March 15, 2008 9:14 PM

DotNetKicks.com said:

You've been kicked (a good thing) - Trackback from DotNetKicks.com

# March 15, 2008 10:34 PM

Johan's Blog said:

Did you know there's T4 ( Text Template Transformation Toolkit ) support inside VS2008 now? Add a file

# April 23, 2008 12:02 PM

Entity Framework Stored Procedure Generation | David DeWinter said:

Pingback from  Entity Framework Stored Procedure Generation | David DeWinter

# April 30, 2008 2:14 PM

GarethJ's WebLog said:

Just lately there seems to be a veritable feast of new blog stuff about VSX (if you don't mind me switching

# May 14, 2008 5:34 AM

David DeWinter » Blog Archive » Entity Framework Stored Procedure Generation said:

Pingback from  David DeWinter  » Blog Archive   » Entity Framework Stored Procedure Generation

# May 23, 2008 3:25 AM

Johan Danforth's Blog said:

Did you know there's T4 ( Text Template Transformation Toolkit ) support inside VS2008 now? Add a file

# June 4, 2008 1:32 PM

Mark Pawelek said:

In your database example, I wasn't able to see the namespaces:

Microsoft.SqlServer.Smo

Microsoft.SqlServer.ConnectionInfo

Is that because I only have SQL Server Express on this PC?

# June 24, 2008 6:05 PM

hiltong said:

I'm not 100% sure if it's available in the full version only, but it seems SMO is part of, or available from Express as well. Check out

www.sqldbatips.com/showarticle.asp and www.codeplex.com/ExpressMaint

# June 25, 2008 12:00 PM

Experimental LINQ to SQL template » DamienG said:

Pingback from  Experimental LINQ to SQL template » DamienG

# June 25, 2008 11:36 PM
Leave a Comment

(required) 

(required) 

(optional)

(required) 


Enter the numbers above: