Thursday, March 10, 2011

SQL Compact Code Generator

More than a year ago, I published a project on CodePlex called SQL Compact Code Generator. Unfortunately, I never managed to find the time to do some work on it and the project was set on a very long hold. A year after I suddenly really needed such a tool and decided that I should put in some hours on the project.

I'm currently working on a large enterprise project where changes to the database schema is done rather frequently, to avoid the pain of updating my data layer after every change I decided to use my code generator.

Here's some details I pulled directly off the CodePlex site.


Project Description
Contains a stand alone GUI application and a Visual Studio Custom Tool for automatically generating a .NET data access layer code for objects in a SQL Server Compact Edition database.

Features:
  • Visual Studio 2008 and 2010 Custom Tool Support
  • Creates entity classes for each table in the database
  • Generates data access code that implements the Repository Pattern
  • Generates methods for Create, Read, Update and Delete operations
  • Generates SelectBy and DeleteBy methods for every column in every table
  • Generates a Purge method for every table to delete all records
  • Generates Count() method for retrieving the number of records in each table
  • Generates CreateDatabase() method for re-creating the database
  • Generates xml-doc code comments for entities and data access methods
  • Generates Entity Unit Tests
  • Generates Data Access Unit Tests
  • Generates .NET Compact and Full Framework compatible code
  • Support for SQL Compact Edition version 4.0
  • Multiple test framework code generation (MSTest, NUnit, xUnit)
  • Transaction support per DataRepository instance (Begin, Commit, Rollback)
  • Code generation options to enable/disable unit test code generation
  • Windows Phone 7 "Mango" support for generating a LINQ to SQL DataContext

Coming Soon:
  • Generate database maintenance code (clear database, shrink/compress database)
  • Support for multiple versions of SQL Server Compact Edition
  • VB.NET Code Support
  • Visual Studio Add-in


Screenshots:

NEW: Custom Tool for Windows Phone 7 "Mango"


Custom Tool


Generating Entity Classes


Generating Data Access methods that implement the Repository Pattern


Generating Entity Unit Tests


Generating Data Access Unit Tests to validate the integrity between the data layer and the actual database



Check it out! You might find it useful too...

6 comments:

Anonymous said...

can this tool be used in .net cf applications ?
TIA

Christian Resma Helle said...

Yes, in fact this tool was designed for that sole purpose

Anonymous said...

Christian, I love this code. Is there a way to get an Id after calling the Create method?

Craig said...

It looks like you use a single static connection object for the whole framework. Will this be ok if there are inserts/updates/delete occuring on multiple threads?

TechEd said...

Hi Helle,

its really nice to for a person like me who is still in learning period...

Pl. let me know if this code can be used for SQL Server Express edition or any other Database by just changing the DB connection function..

and if is their any project of this kind which we could use it for Web Application development backend

Anonymous said...

rectification

I fear that my earlier msg displaying as some Naveen...
I can't say why its displayed like this...May be some one else had been logged in from this PC earlier!

But i am Mandeep Singh.