Sunday, June 14, 2015

SQL Code Generation Tool

The SQL Code Generation Tool is an open source project that I created to help automate the creation of stored procedures, model objects, and the data layer classes in the majority of the projects I'm involved in.

These scripts started in late 2010 when I simply got tired of manually coding VB.Net model classes. Over time, I added additional scripts to code gen the basic stored procedures, model classes, and data layer classes that I generally needed for each entity in my project. Initially the scripts only generated VB.Net code for the model/data layers; however, they now support both VB.Net and C#.

The scripts have went through 3 major rewrites/refactoring to get to their current version (v3.0) and now work with SQLCMD, which makes generating your files (procs, model, data) very simple.

Please keep in mind these scripts were written for a specific style of n-tier architecture, so they may or may not fit your needs out of the box. For most of the applications I work on there is a Web layer, Model layer, Data layer, and a backend SQL Server database (business/data).

These scripts more or less automated 90% of the routine tasks I would encounter after designing a database/table. I almost exclusively use these scripts to create the initial set of stored procedures, model classes (C#, VB.Net), and data layer classes (C#, VB.Net). Once generated I customize them as-needed to fit the project's needs (e.g. adding advanced filtering to stored procedures, adding derived properties to the model class, etc).

Head over to the GitHub repository for more information.

https://github.com/mpavey/sql-code-gen

Matt Pavey is a Microsoft Certified software developer who specializes in ASP.Net, VB.Net, C#, AJAX, LINQ, XML, XSL, Web Services, SQL, jQuery, and more. Follow on Twitter @matthewpavey

0 comments: