How to setup Code Smith samples

Many of the examples that relate to the Database Explorer API, Domain Model API and Models API are written using a code generation product called Code Smith; though none of the examples rely on anything specific to this product. There are plans to create samples or full models on other platforms as well such as ArchAngel and T4 which ships with Visual Studio 2008.

However, for now the samples are in Code Smith so for those not too familiar with Code Smith (and you won't need too much knowledge to get started) I thought I'd give a brief tutorial and installation instructions for the samples.CodeSmithShortCuts


To get up and running you need to follow these steps, if you already have Code Smith you can obviously ignore the download and install step.

  1. Download the samples for the framework here at the bottom of the page.
  2. Visit and download the current version of their tool. They give you a 30 day trial.
  3. Copy the framework dlls from the download into the Code Smith installation directory. By default C:\Program Files\CodeSmith\v4.x (Its important that Code Smith is not running when you do this)
  4. Next copy the script files from the samples somewhere you like.
  5. Now you can start up Code Smith and link to where you saved the scripts see figure 1.
  6. Before you can run the script you need to setup a reference to your database. To do so you have to add a database using the Schema Explorer. See figure 2
  7. Run your scripts.
  8. Provide feed back!CodeSmithDatabaseConnection

If you've never run a script in Code Smith before you need to double click on the script file (you can also right click and select execute) then compile the code to ensure there's no issues (ctl-shift-b). Then you need to select the database you referenced in step 6 from the properties. Pressing F5 (same as Visual Studio) will execute the script and output the results to the window. Code Smith provides many features which this quick tutorial won't go into, however if you plan to build templates with it, you can get a lot of information from their web site.