Directions

We don’t yet support SQL Server Express. We’ve tested only with SQL Server 2005, but anticipate SQL Server 2000 and 2008 would also work

If you haven’t built using the Build Notes – do that before continuing.

Setting Up the Database

You need a database available that has single column primary keys on all tables. Neither Northwind nor AdventureWorksLT, nor NorthwindEF fill this requirement, so we’ve created a sample database for contacts. We anticipate upgrading this database periodically, so don’t include data, or plan to version your data. The only reason you’d want data in this database is for testing.

Assuming you plan to use GenDotNetSample
  1. Create a database with some name on your server, preferably GenDotNetSample
  2. Open your favorite query tool (like Microsoft Sql Server Management Studio) and change the name in the USE statement (first line) if you named it something other than GenDotNetSample
  3. Run the scripts in the Database directory
  4. Check that this database exists and contains four tables and no stored procedures

Create the ORM File

The ORM file must be present for the database to be managed correctly. While the morphing process supports an extremely rich mapping, it’s incredibly complex and we plan to abandon it in favor of a better process in April. Thus, we are not documenting the potential of this file in detail, just explaining that it must be there. The contents for GenDotNetSample are:

// multi-line
<orm:MappingRoot xmlns:orm="http://kadgen.com/KADORM.xsd"
xmlns:kd="http://kadgen.com/Special.xsd"
MapDataStructure="GenDotNetSample"
TransactionType="ADONET"
Namespace="GenDotNet.Samples"
TransactionForRetrieve="false"
RetrievePattern="Select_Object"
RetrieveChildrenPattern="SelectChildrenFKeyObject"
RetrieveAlternatePattern="ByCriteria"
SetSelectPattern="SelectAll_Object"
CreatePattern="Insert_Object"
UpdatePattern="Update_Object"
DeletePattern="Delete_Object"
Generate="CRUDS"
CollectionType="Plural">
<!-- SQL Function replacements help the SQL translator. This is used for
constraints and defaults -->
<orm:SQLFunctionReplacement>
<orm:SQLFunction Name="getdate" ReplaceWith="System.DateTime.Today" NETType="System.DateTime"/>
</orm:SQLFunctionReplacement>

<!-- Mapping definitions. -->
<!-- To evaluate the result of these mapping, look at the Retrieve stored procedures -->
<orm:Mapping Name="GenDotNet.Samples">
</orm:Mapping>

</orm:MappingRoot>

// single line
If you named your database something other than GenDotNetSample, you must change the name in the MapDataStructure attribute in the MappingRoot element.

Run the Project

Run the project either in debug mode or via the executable. You’ll see a temporary (and very ugly) user interface.
  1. Select your server if needed
  2. Select the GenDotNetSample database or other database
  3. Press the button “Make Sp Metadata”
  4. Press the button "Generate Select"

Make Sp Metadata accomplishes two things. It extracts metadata from the database and it morphs it based on the ORMFile. You can run these steps separately via these buttons.

Generate Select creates a script in the SQL Output directory and loads this script into your database. Feel free to delete your stored procedures and rerun the tool to recreate them.

Last edited Mar 29, 2008 at 10:35 PM by KathleenDollard, version 7

Comments

No comments yet.