George J.'s profile“Daily Cycle”PhotosBlogLists Tools Help
    1/12/2009

    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:

    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.

    Comments (6)

    Please wait...
    Sorry, the comment you entered is too long. Please shorten it.
    You didn't enter anything. Please try again.
    Sorry, we can't add your comment right now. Please try again later.
    To add a comment, you need permission from your parent. Ask for permission
    Your parent has turned off comments.
    Sorry, we can't delete your comment right now. Please try again later.
    You've exceeded the maximum number of comments that can be left in one day. Please try again in 24 hours.
    Your account has had the ability to leave comments disabled because our systems indicate that you may be spamming other users. If you believe that your account has been disabled in error please contact Windows Live support.
    Complete the security check below to finish leaving your comment.
    The characters you type in the security check must match the characters in the picture or audio.

    To add a comment, sign in with your Windows Live ID (if you use Hotmail, Messenger, or Xbox LIVE, you have a Windows Live ID). Sign in


    Don't have a Windows Live ID? Sign up

    @Bob Original T4 templates in SubSonic were replaced by these templates. Google Code has the latest version, now.
    Feb. 22
    Bobwrote:
    @George - Are these the latest templates or are the ones on googlecode newer? Thanks.
    Feb. 11
    @Christian Weyer: Get the latest version of the templates. I have fixed the problem.
    Jan. 26
    OK, close: the providerName attribute was missing (usually I never set/use it).
    Jan. 19
    Oh: and I *do have* the connectionString in app.config...
    Jan. 19
    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!
    Jan. 18

    Trackbacks (5)

    The trackback URL for this entry is:
    http://gcapnias.spaces.live.com/blog/cns!1A746C4E01342B70!499.trak
    Weblogs that reference this entry