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 – play the video in full-screen:

The templates used for the video can be found in my SkyDrive:

http://cid-1a746c4e01342b70.skydrive.live.com/embedrowdetail.aspx/SubSonic3/SubSonic3T4.zip

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.
  • 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.

Advertisement

About George J. Capnias
Software Engineer, Web/Windows Applications Developer in variety of bussiness applications. Microsoft Certified Professional since 1999, currently holding MCT, MCSD(DNA,.NET), MCDA(SQL 2000), MCAD, MCP SB. MVP in VSTO technologies. INETA Country Leader for Greece. Specialties: HTML/DHTML/XHTML, Script Technologies(JavaScript, VBScript, Script Components), CSS,XML/XSLT, VB6 (Client/Server, 3Tier, COM), ASP(IIS4, IIS5, E-Commerce, Site Server 3 ,Site Server Commerce 3), ASP.NET(IIS6, IIS7.x, Community Portals, Telligent's Community Server), VB.NET/C# (Windows/Web Applications, Windows/Web Services, Serviced Components), MS Commerce Server 2000/2002, SharePoint Server 2001/2003/2007, SharePoint Technologies(WSS v2 & v3,Web parts, portals), Office technologies (Smart tags, Research services, OpenXML)

6 Responses to 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 )

Connecting to %s

Follow

Get every new post delivered to your Inbox.