I was quite overwhelmed recently when I started researching OR/M tools for the latest ASP.NET 2.0 project at work. There are so many to choose from, all with their own unique take on what it means to be a good object-relational mapping tool. I only wanted to spend a day or two researching/evaluating OR/M tools, and I narrowed it down to SubSonic and EntitySpaces for my final showdown.
SubSonic
I first heard about SubSonic about 6 months ago from one of the many ASP.NET blogs I subscribe to. The goal of the project is to bring some of the cool RAD tools from the Ruby-on-Rails world into ASP.NET. One of the nicest features of SubSonic is that it mostly “just works” without too much effort. There’s no crazy-complicated XML mapping files (I’m looking at you NHibernate…) or mountains and mountains of auto-generated code to dig through (N-Tiers). SubSonic utilizes a cool feature of the VS2005 and ASP.NET environment called “Build Providers”. All you have to do is make a few adjustments to your web.config file, add a special file to your App_code directory and you’re done! Whenever you compile/build your VS solution, SubSonic reads your database schema and dynamically generates Data Access classes.
EntitySpaces
I only recently became familiar with EntitySpaces. A former co-worker of mine really likes the d00dads architecture, the precursor to EntitySpaces. EntitySpaces takes the code-generation approach, utilizing the popular free code-generation tool MyGeneration. EntitySpaces is essentially a few .NET dll’s and some MyGeneration code templates. You load up MyGeneration, open the Entityspaces templates, point them at your database tables, and MyGeneration will spit out a bunch of Data Access and Biz Logic classes in either C# or VB.NET. My favorite features of EntitySpaces are it Scaffolding support (to auto-generate administration screens for all of your database tables) and its great support for hierarchical data models.
Shot of a scaffold page (notice the drop-down auto-generated for the FK column)
![es2_CropperCapture[1].Jpg](/Portals/0/es2_CropperCapture[1].Jpg)
SubSonic
Good Stuff
· Free and Open Source!
· Easy to get started / mild learning curve
· Dynamic Queries
· Strongly-typed wrapper classes for all your stored procedures
· Active forums, frequent releases
Chinks in the armor
· Scaffolding support is buggy
· Doesn’t handle GUID keys very well
· Weak support for navigating PK/FK relationships
· Geared towards ASP.NET only (WinForms is possible)
EntitySpaces
Good Stuff
· Auto-generated scaffolding is very powerful / time-saving
· Dynamic Queries
· Very good support for navigating PK/FK collections in code
· Able to regenerate Data Access code without affecting your custom business logic
· Serialization of objects for web services, etc.
· Active forums / support
Frown Face
· Not free or open source ($80 for Express edition)
· No strongly-typed access to stored procedures (it is scheduled for next release though)
Final Thoughts
In the end I chose to drop the $80 for EntitySpaces because of its superior Scaffolding and PK/FK Hierarchical support, both of which have been big time-savers so far, allowing me to focus more on the “real guts” of my application instead of Data Access code. The addition of stored procedure wrappers in the next version will make it even more attractive in my opinion. However, I’m definitely going to keep an eye on the SubSonic project, since they are adding features all the time. The biggest things preventing me from using SubSonic right now are the relatively buggy scaffolding support for GUID data types, as well as the weaker support for navigating hierarchical PK/FK collections in code.