I've been playing with ways to write a solid (and even SOLID :)) architecture with ASP.NET MVC. I started with a plain LINQ to SQL approach, and then migrated to LightSpeed, and finally ended up checking out S#arp last week. Here are my notes of pros/cons on each approach. Yes, I could (and most likely will) address some concerns by writing code for it. This is more of a laundry list of the state of things as I see them at this point in time.
LINQ to SQL
Pros
Cons
- MS is talking about phasing LINQ to SQL out and forcing people towards Entity Framework. I'm pretty sick of chasing MS's data-access strategies around every year.
- LINQ to SQL mostly defaults you to a 1:1 mapping between your database and your model.
- Support for modifications to the schema sucks, to be generous.
- No UnitOfWork concept. Of course, as I prepared this blog entry, I found this article published just today, so maybe that would address this point.
LightSpeed
Pros
- Support is outstanding.
- Nightly builds are available.
- Visual designer.
- Proven patterns bundled in their core libraries (UnitOfWork, Repository, Entity, etc.).
- Picks up changes from the schema flawlessly.
Cons
- Commercial and propietary.
- Lacks quite a bit of LINQ support. For example, groupby and join are not supported. This meant that I use LINQ to SQL when I need these features. Fortunately, that's all isolated to my report module, so it's not as horrible as it could be.
S#arp
Pros
- Open Source
- Uses standard, widely adopted open source libraries: NHibernate, Windsor, etc.
- Convention over Configuration
- Scaffolding
Cons
- I'm not digging the T4 templating mechanism. They conflict with VisualSVN and Developer Express tools, and having to write a template for each and every entity is cumbersome.
- No visual designer
- No ability to import entities from an existing database. Yes, they like DDD, but in almost every project I've been a part of, the database is the thing that already exists.
- No UnitOfWork pattern (I might be able to fit code out there that does this in with S#arp). The [Transaction] attribute approach feels a bit dirty.
- The scaffolding is a bit too simple. It doesn't build up object graphs with links (for display) or SelectLists (for editing). Yes, I can add that. It probably will get that functionality at some point, too. But it doesn't do it right now.
For now, I think I'll be staying with LightSpeed, but I'll be watching S#arp very carefully.