SubSonic v3’s T4 Templates


I short post in order to provide Subsonic v3’s T4 templates based on T4Toolbox, and a short demonstration video.

Starting with the video – download and play the video in full-screen:

The templates used for the video can be found here:

Finally some short notes about the templates:

  • When I saw the T4 templates that comes with the first SubSonic v3 Alpha, I must say I was scared! I really liked the smooth code generation method Subsonic v2 had. As soon as you drop the T4 templates in your project, error messages start popping from everywhere.
  • Before Christmas I found out T4Toolbox project in CodePlex. I knew nothing about T4 template code generation back then, but it looked like that was the way SubSonic v3 T4 templates should be implemented. Thanks to Oleg Sych weblog posts, and Clarius’ T4 Editor Community Edition, these templates were created. I only wish, I had the Professional version…
  • In order to use the templates in a project, first you have to make sure that your application has a app.config file with connection strings, and the Subsonic.Core.dll referenced. Then you can add the T4Toolbox folder and the SubSonic3 folder in your project. Thanks to T4Toolbox templates’ infrastructure, all the templates are implemented as classes and they don’t make code generation – there are no error produced and no popping error messages.
  • The code generation procedure is initiated from the last file added to the project – SubSonic3Creator.tt has all the information needed to make SubSonic’s classes generation successful. It holds the connection string’s name to the database, the namespace under the classes are generated, as well as the database name for SubSonic’s reference. All the files created are under this template – every time this template is saved, the code generation procedure is initiating.

    S3T4_1 S3T4_2 S3T4_3
  • You are free to use the templates in your projects – remember these SubSonic T4 templates are in early stage of developing and may contain errors. In order to avoid T4 template code generation errors you can remove the value, attribute Custom Tool is holding for each template in T4Toolbox and Subsonic3 folders. Only SubSonic3Creator.tt has to maintain the value in the attribute.
Advertisements

George Capnias is working as Software Architect and Development Manager. His developing career started as soon as he left high-school and got a job as a programmer for a small software house in Athens. He started developing with Microsoft’s products as soon as Visual Basic for Windows came out. Since September '93, he was member in one of the greater BBS in Athens, where he served as a moderator for Windows related forums till '98. He started developing Web applications in '96. September '99 he started working as a trainer for Compact SA (Microsoft Gold Certified Partner for Learning Solutions - CPLS). He is certified as Microsoft Certified Professional & Site Building (MCP+SB), Microsoft Certified Solution Developer (MCSD) for Visual Studio 6 and Visual Studio 2003, Microsoft Certified Database Administrator (MCDBA) for SQL Server 2000, Microsoft Certified Technology Specialist (MCTS) for Windows & Web Applications, Microsoft Certified Professional Developer (MCPD) for Windows & Web Applications and he has the status of Microsoft Certified Trainer (MCT). He is the leader of dotNETZone.gr, an Athens, Greece, user group for Greek software developers using Microsoft’s .NET platform. He is delivering technical presentations and workshops for Microsoft Hellas to audiences like developers, ISVs. He was awarded as MVP for 'Visual Studio and Development Technologies' in '16 and '17, for 'ASP.NET/IIS technologies' in '06 and '15 and as MVP for 'VSTO technologies' in '07, '08, '09, '10, '11, '12, '13 and '14.

Tagged with: , ,
Posted in SubSonic
6 comments on “SubSonic v3’s T4 Templates
  1. Christian says:

    I get this error:Error 1 Running transformation: System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.VisualStudio.TextTemplating57678390C6C78990C1AE75C135158D4B.GeneratedTextTransformation.SettingsManager..ctor(IServiceProvider ServiceProvider) in c:\Temp\SubsonicTest\SubsonicTest\SubSonic3\SettingsManager.tt:line 44 at Microsoft.VisualStudio.TextTemplating57678390C6C78990C1AE75C135158D4B.GeneratedTextTransformation.TransformText() in c:\Temp\SubsonicTest\SubsonicTest\SubSonic3Creator.tt:line 21 C:\temp\SubsonicTest\SubsonicTest\SubSonic3Creator.tt 1 1 Any idea?Thanks!

  2. Christian says:

    Oh: and I *do have* the connectionString in app.config…

  3. Christian says:

    OK, close: the providerName attribute was missing (usually I never set/use it).

  4. George J. says:

    @Christian Weyer: Get the latest version of the templates. I have fixed the problem.

  5. Bob says:

    @George – Are these the latest templates or are the ones on googlecode newer? Thanks.

  6. George J. says:

    @Bob Original T4 templates in SubSonic were replaced by these templates. Google Code has the latest version, now.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: