Update: the title of this post is probably misleading as it's not all the steps for using SubSonic. There's plenty of material out there already on that (for i.e. how to set your build provider for Web Site Projects, how to set your config files for class libraries or Web Application Projects, how to set up your database, etc.) - the best place to start looking for that info is www.subsonicproject.com. This post refers to how to get using the subsonic.exe from within Visual Studio to regenerate your code on demand.

I've been using SubSonic for one of my latest projects and I really like what I've seen thus far. I'll save a further review for a possible other post, but since I've just repaved my machine and I'm setting everything back up again, I had forgotten how to configure the Visual Studio IDE to easily regenerate code using SubSonic (with a Web Application Project or Class Library - not the auto build provider).

Rob Conery has a good Webcast on how to do it all (if you haven't viewed it yet, head over now and do so), but it's a little tedious to work your way through the whole Webcast in order to pick out tool setup instructions. Therefore, I figured I'd jot down how to set up SubSonic DAL generation scripts for easy generation of code in Web Application Projects or Class Libraries. In other words, instead of having to open a command prompt all the time and specify what you want generated and where etc., just create some toolbar items and/or macros to do it for you on demand right in the Visual Studio IDE.

Create SubSonic toolbar with SubSonic DAL button (optional)

Select External Command n where n is the position of your newly referenced SubSonic DAL tool in the Tools menu:

In the screen shot above, it's External Command 6. On a new machine with nothing else on it, the number will be External Command 2 as there's only one other tool before it in the menu (Dotfuscator Community Edition).

Drag and drop External Command n to the floating SubSonic menu you had just created:

When you now press close on the Customize dialogue, your SubSonic menu should now reflect your tool name. In this case that would be "SubSonic DAL."

Drag your floating toolbar to wherever you want it on your menu bar. Now, to generate code you can click on it from the Tools dropdown menu, or directly on your menu bar. Of course, you could just go further and create a macro.

Note: make sure you're actually in your SubSonic project where your app.config is located when you execute the command - nothing bad will happen if you don't...it's just that nothing good (code generation) will happen either.