Hibri Marzook Musings on technology and systems thinking

Scaffolding with ASP.Net

Many web applications have a back end “admin” pages to manage tables in the database.  These pages exist solely to perform CRUD operations against a single table. Sometimes with a bit of validation.

It is tedious work if you have to create and write the same code  for each table and to maintain them. To make this task somewhat easier, there are solutions that look at the database structure, and generate the data access code and the asp.net pages.

The latest and greatest of them is ASP .Net Dynamic data. This uses LINQ to SQL for data access. Its quite easy to get a site up and running using this.

Mono Rail has an ActiveRecord scaffold.  This uses Castle ActiveRecord and Nhibernate to generate the scaffold. However, this doesn’t generate the database to object model mapping automatically.  Classes that inherent from an ActiveRecord base have to be created first. Fields and relationships have to be defined in code. When this is done its all a breeze. Its a good way to get to grips with MonoRail.

 

Subsonic which I’m using on a project now, has two methods of operation. It has a set of scaffold controls which you can use on any asp.net pages to get CRUD functionality, and it also has the option to generate the asp.net pages and the data classes. The data classes generated by subsonic use the active record pattern too. The code generated by subsonic can be modified if you need to do so. After the code is generated these are normal asp.net pages to which you can add validation, combine with master pages etc..

Subsonic and Asp.Net dynamic data offer the quickest way to get up and running.  Subsonic and MonoRail offer the possibility to extend the application when things get more complex. The data classes generated can be reused when the application grows beyond a simple prototype or admin section.

By Hibri Marzook

Discuss this post with me on @hibri