Can the Entity Framework replace CSLA?

Can the Entity Framework replace CSLA?

Old forum URL: forums.lhotka.net/forums/t/10108.aspx


frankhoffy posted on Friday, February 25, 2011

I just watched this great little video series on creating a WPF and Silverlight MVVM application.  In the sample, he started with an Entity Framework model and wrapped it in a WCF layer.  The WCF layer detached the entity object and returned it to the client.  The client then called a Save method in the WCF layer, which attached the entity object to the context, flagged it as dirty, and saved the changes to the database.  He also included a small example of how to include a business rule, but the focus of the presentation wasn't on Entity Framework.

All of this made me wonder if this sort of paradigm could replace what CSLA does for us.  I've been using CSLA for years, but I haven't developed an Entity Framework application yet.  What sort of things would I be missing out on?

tmg4340 replied on Friday, February 25, 2011

This has been discussed a few times on the forum, and a search will pull up quite a bit of information.  But the short answer is "no".

EF is an ORM, and as such is not really designed to develop the kind of rich business objects that CSLA provides.  For one, there isn't any integrated business-rule subsystem, nor is there much in the way of authorization rules either.  There's also no infrastructure for object graphs (e.g. child dirty detection).  This isn't all that it's missing, but these are pretty decent chunks of functionality.  But like I said, it's an ORM, and most people don't consider those types of things to be the purview of an ORM.

I don't know how old that video series is, but from what you've described, it sounds like it's actually a lot closer to WCF RIA Services.  This accomplishes some of what CSLA does, and possibly over time could replicate much of what CSLA does for Silverlight, but it does so in a different fashion.  And RIA Services is (currently) restricted only to Silverlight (and, I would presume, WP7), while CSLA isn't.  RIA Services also takes a very different view on what your model should look like, which is why CSLA and RIA Services don't really play well together either.

HTH

- Scott

Curelom replied on Friday, February 25, 2011

The CSLAExtension project found on the Code generation index of this site works in concert with EF.  Generating the CSLA classes directly from the EF entities.  It's worth a look-see.

http://t4csla.codeplex.com/

 

Copyright (c) Marimer LLC