views:

189

answers:

1

I've just started using SubSonic 3 and I'm using the ActiveRecord T4 template.

If I make a change in the database (add a column to a table for example), what is the correct method for forcing the code produced by the T4 templates to be re-generated?

At the moment I'm just deleting the ActiveRecord folder in my project then dragging the template folder back in again. There must be a better way?

Update:

In addition to Skinniest Man's answer below, I also noticed an icon at the top of the Visual Studio 2008 Solution Explorer called "Transform All Templates". This will generate code from all templates found in the currently selected project.

+4  A: 

Right-click on the .tt file (or files) in Visual Studio and select "Run Custom Tool".

Skinniest Man
Nice one. Is there a way to make that a build step in VS2008?
Kev
Haven't tried this yet myself, but you can probably set up a pre-build step to run the transformation. I just found this link[1] from here[2]. 1 - http://geekswithblogs.net/EltonStoneman/archive/2008/07/25/an-msbuild-task-to-execute-t4-templates.aspx 2 - http://www.hanselman.com/blog/T4TextTemplateTransformationToolkitCodeGenerationBestKeptVisualStudioSecret.aspx
Skinniest Man
Sorry that didn't format very well. But at least the links are there. :)
Skinniest Man
Good enough for me and food for thought. Appreciated.
Kev