Saturday, July 28, 2007

Castle Active Record Code Generator

Code Generation CompletedCode Generator asks about overwriting a file
I have finally released my Code Generator to Google Code as Active-Record-Gen. What does it generate? It generates ActiveRecord classes mainly, but I have used it to generate stored procedures and sys-admin scripts as well. This code generator does not (yet) generate a full Windows application project or a Mono-Rail web site, but the generated code could be used in either. In fact, with a few tweaks, this could be used to generate NHibernate "poco" and .xbm files. If you want to know more, look at the screen shots above, or head over to Google Code and run it. In my haste to make my first EXE release before supper, I forgot to add the Template directory, which should be at the same directory level as the EXE and config files. I just (1.5 hours later) uploaded a new EXE, but 2 people have already downloaded the EXE (not the source though).

As for the basic table object, it is built with the following assumptions:

Table name is plural, class name is singular.
Field "ID" is the primary key (at some point, this decision will be based on the SQL schema.
Fields ending in _ID are foreign keys (Department_ID is a foreign key to the Departments table).

Generated objects have the [ActiveRecord], [PrimaryKey], [Property], and [BelongsTo] attributes.


Anonymous Mehmet E. SAPMAZ said...

nice app. will it support mysql?

March 04, 2010 7:09 AM  
Blogger Roy Tate said...

It currently uses Microsoft SQL Server's Information Schema. There are only a few places where it would need changed to support MySQL. 1) change SELECT statements that gather tables and columns. 2) change the data type mapping.

March 04, 2010 10:27 AM  

Post a Comment

Subscribe to Post Comments [Atom]

<< Home