Sponsored By Aspose - File Format APIs for .NET

Aspose are the market leader of .NET APIs for file business formats – natively work with DOCX, XLSX, PPT, PDF, MSG, MPP, images formats and many more!

T4 Templates for Code Generation Screencast

T4 Template ScreencastI put together a quick screencast showing how to leverage T4 Templates in Visual Studio 2008 for Code Generation:

I show step-by-step how to create a simple T4 Template and then how to generate various Entity, Data Access Object, and Factory Classes using more advanced T4 Templates that one might use to create a simple custom data access layer. I have seen other screencasts that have used SQL Server Management Objects, but in my case I use database schema related functionality in good ‘ol ADO.NET. Although I wouldn’t use this technique to build a data access layer given all the cool code generators and O/R Mappers, it is a pretty decent way to show the possibilities with T4 Templates.

I picked up a new iPhone 3G the other day and absolutely love it, so I also created a version of the screencast that you can download and play on the iPhone. In fact, several of the more recent Unity and Enterprise Library 4.0 Screencasts now have an iPhone version.

If you are interested in some of the ADO.NET techniques I used in the screencast to get database schema information, check out the show notes with links to various tutorials.

I hope the screencast is useful.

This entry was posted in Uncategorized. Bookmark the permalink. Follow any comments here with the RSS feed for this post.

6 Responses to T4 Templates for Code Generation Screencast

  1. joshka says:

    Hehe, no it was not too distracting. Thanks for the screencast.

  2. Damien Guard says:

    I just posted a T4 template to build a LINQ to SQL DataContext and associated entities from a DBML allowing you to effectively customize the code generation phase.



  3. David Hayden says:


    I tend to find some useless phrase and repeat it during these screencasts. Normally it is “actually” or “essentially” so consider “go ahead” a refreshing change :) As try as I might to not do it, the nervous tick always comes out.

    Hopefully it is not too distracting…

  4. David Hayden says:

    Thanks, Steven. I didn’t realize T4 Templates were the next subject at our meeting. You will be missed.

  5. joshka says:

    You say “go ahead” too much… 😉 I counted 6 times in the first 10 minutes.

  6. Thanks David. I’m going to be out of town for the August SarasotaDevs meeting, which is on this subject. I think that you gave a great overview of this technology.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>