CodeSmith Generator CSLA Templates Part 2: The Quick Start

In Part 1: The Introduction was an overview of the CodeSmith Generator CSLA templates we are developing at CodeSmith. In this post, I am going to go over how to use the CSLA quick start and the new improvements resulting from customer feedback (Keep the feedback coming!).

First launch CodeSmith Generator Studio and under the Frameworks node open the CSLA Folder.

There are a couple of folders in the CodeSmith.CSLA folder

Folder Name

Description

Common Contains the supporting CSLA assemblies and the Visual Studio templates to create the project.
CSharp Contains the C# templates.
Source Contains the source code to the quick start and the API that the templates use.
VB Doesn’t exist yet but will contain the VB.NET templates.

Now double click on the quick start template, the property grid should now be populated with the quick start properties.

CodeSmith Studio (4) 

Next select “” button for the Source Database property and select your database you wish to generate against. In this example I will select the PetShop database. The quick start will now populate the property grid most common settings. From here configure the settings to your liking and click generate. Microsoft Visual Studio should now launch unless you set Launch Visual Studio property to false.

PetShop - Microsoft Visual Studio (Administrator)

Next right click the PetShop.UI project and select Set as Startup Project

Now when you select build or debug your project will start generating.

The UI Project is a place holder project for you to start building your application. So now that you have the general idea on getting up and running quickly with the quick start lets see what it takes to customize the type of each entity. Lets right click the Entities.csp template and select Manage Outputs.

After the manage outputs dialog comes up double click on the Entities.cst item.

Earlier in the CSLA beta we had 14 different outputs instead of one. Now all the settings are in one output (Entities.cst). Say you wanted to change the types of your entities from an EditableRoot to a EditableRootChild object. Just use the familiar table picker and change it. It will check to make sure there is no conflict and that any child lists are populated. For example if you had no entities selected and you added a table to EditiableChild it would look through all the lists and if a list entity was not found it would add the table to the EditableChildList. This makes it extremely easy to configure your Business objects.

Please give us your feedback on the new CSLA templates!

3 comment(s)

nampord wrote on January 23, 2008

Blake

thanks for the new template. It certainly is a whole lot simpler to manage than the previous csla template based on inlcude files.

However what is a bit confusing to me is that your template  seems to assume that for every business object  in a csla based application there is a corresponding database table. (i.e a 1-to-1 mapping between objects and tables). This will however rarely be the case. ( see e.g. the ProjectResource object in R.Lhotka's book. How would one create the ProjectResource object with your template? ) How can I map from tables to entities, if the ralationship is not 1-to-1 ?

Frank