At first, SubSonic was built with Web Projects in mind.  With it's fancy build providers and App_Code folder, it looked great but since I primarily use Web Application Projects it didn't help me much.  With the 2.0 release SubSonic not only supports WAP, but also WinForms as well.  It now has "SubCommander" which is a command line code generator which with some help from Visual Studio makes code generation a one click affair.  There is also a nice "add-in" for visual studio, but that has some good documentation and is pretty easy to install (ie Double click the installer).

A lot of their walkthroughs and tutorials almost work for my environment.  Some things are a bit different though so I'm going to go over it here.  I'd like to outline my own setup (which has been cobbled together from Rob's and others) for 3 reasons: so you can contrast against existing docs, so you can give me a hard time about how I could do this better, and the next time I have a new project I don't waste time refiguring it out :)

Setting up the projects

The first thing I do is setup a Data project within Visual Studio.  This project essentially contains my DAL. I created a "Generated" folder just like Rob does in his video.  I create a app.config in the root folder.  Then I create two other config files: Db.Config and SubSonic.config.  In those I put my database connection string and my subsonic configuration respectively.  I then click on the Db and SubSonic config's and set their "Copy to Output Directory" to "Copy if newer".  I also place a reference to the SubSonic.dll which I have copied and pasted into a "Dependancies" folder that resides in my solution root.

Everything looks like so:

App.Config:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="SubSonicService" type="SubSonic.SubSonicSection, SubSonic" allowDefinition="MachineToApplication" restartOnExternalChanges="true" requirePermission="false"/>
</configSections>

<connectionStrings configSource="Db.config" />
<SubSonicService configSource="SubSonic.config" />
</configuration>

Db.Config

<?xml version="1.0" encoding="utf-8" ?>
<connectionStrings>
<add name="SqlServer" providerName="System.Data.SqlClient" connectionString="yours"/>
</connectionStrings>

SubSonic.config

<?xml version="1.0" encoding="utf-8" ?>
<SubSonicService defaultProvider="Data">
<providers>
<add
name="Data"
type="SubSonic.SqlDataProvider, SubSonic"
connectionStringName="SqlServer"
generatedNamespace="Wtf.Data"
fixPluralClassName="true" />
</providers>
</SubSonicService>

Notice in my SubSonic config that I put the generatedNamespace="Wtf.Data".  This will wrap a nice namespace around all of my generated DAL code.

Over in my web project, I name it similarily: [project name].Web.  I include references to my Data project and SubSonic.

I place the same items in my web.config, except my configSource value's change.  Instead of Db.Config they are automatically copied to the bin directory (remember when we selected "Copy if newer") so it needs to be "bin\Db.Config" or like so:

<connectionStrings configSource="bin\Db.Config" />

The SubSonic config section still needs to be in the web.config, so you'll need to include that plus the other pointer to the Subsonic.Config like:

<connectionStrings configSource="bin\SubSonic.Config" />

This comes in handy if you have multiple points (Tests for instance) that need this info.  Feel free to sprinkle this around to other parts of your config file as needed.  Tasty!

Creating a button to generate the DAL

Rob again demonstrates this in the same video linked above (and which if I were you, I'd watch in addition to reading this if you haven't already), but pictures are faster, and I had a few changes. 

Go to the tools drop down menu in and select "External Tools"

Click on Add and then input the following:

The biggest change between this and the video, is that I don't have a App_Code folder.  As such, I just wanted the generated file to go to a Generated folder, not "App_Code\Generated".

The other change was instead of the using $(ProjectDir) I used $(SolutionDir) and then gave the folder path to my Data project.  This allows me to be anywhere in my solution when I click the button that I'll be making here in a second.  The "Prompt for arguments" I think is optional.  I'd test it out for a few times, and then when comfortable, uncheck it.  One LESS button to click (yeah, I'm lazy)!

Click "Ok" to get back to VS's main screen.  On the "Tools" drop down you should now see "Generate SubSonic DAL".  Preeety.

This may seem stupid at the moment, but start from just below "Add-in Manager..." and start counting the items.

Remeber this number as it is your lucky number.  In my case 7 (John Elway?!?) is the lucky number.  Since we have our lucky number we can now make our shiny button.  Click on a blank space in the tool bar and then click "Customize".

Scroll down a bit, select "Tools" and then on the right find "External Command X" where X is your lucky number.  Drag the "External Command X" to the little box that appears.  You should now have a "External Command X" in your box.  How lucky!

When you click close, "External Command X" will magically turn into a button called "Generate SubSonic DAL" (or whatever you decided to call it).  Drag the button up to your toolbar to implant it in Visual Studio.  Now whenever you make a database change, just click the button and you're ready to rock.  Ready to Rooollll.

Notes: I wonder, just wonder if there is still a way to bind a database change to xp_cmdshell to autofire off SubSonic.exe?  Then there would be no button!  No button!  AHhahahah haha hAHah hAAAaaaa.