Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Subsonic 3 VS Entity Framework

Anyone worked with Subsonic3 and Entity Framework here who can tell me the pros and cons? This is my first time attempting to try these. Subsonic is easy to setup so as the Entity Framework. I am not sure if Entity Framework works with other databases as SubSonic does like MySql PGsql etc...? I read this post (http://www.timacheson.com/Blog/2009/jun/entity_framework_vs_subsonic) which is convincing enough to chose Entity Framework over SubSonic. But I wanted a second opening.

like image 572
Shuaib Avatar asked Jul 20 '09 13:07

Shuaib


2 Answers

Well, these two are quite different beasts!

Subsonic 3 is a great tool for simply and easily mapping a database structure pretty much 1:1 to object classes, where each class will be an exact representation of the table in the underlying database (as is the case with Linq-to-SQL as well).

Entity Framework on the other hand targets much more complex scenarios, where your domain or object model (your classes) will not necessarily map 1:1 to database tables. That's why the EF has a trilogy of XML files - one describing the conceptual level (your domain objects), one the storage level (the database layout), and the mapping in between those two.

IMHO, Subsonic 3 and Linq-to-SQL are perfect for quick, small to medium size projects, where your database is flexible enough to change if need be, and where you have a pretty straightforward mapping of your objects to tables. EF really shines in large-scale enterprise apps, where your database level might be set in stone, and you can't change it - or your app needs to "survive" even if the underyling database changes.

Totally different beasts - totally different audiences, in my opinion.

Marc

PS: I wonder if Tim was really using Subsonic 3 in this comparison, and what exactly he was doing. My gut feeling would have been that EF would be the "bigger" overhead and thus might be a bit less performant (but more flexible, and in Enterprise scenarios, that's worth its weight in gold, even when sacrificing some performance for it)

like image 187
marc_s Avatar answered Sep 22 '22 21:09

marc_s


In case this helps, in my benchmarks I used Subsonic 2.1 (as stated) and compared data access layers in a moderate load scenario (methodology as stated). I provided code, so my test can easily be replicated.

If you subject the system to load, reproducing the conditions in a web application while in use, EF proves to offer much better performance. Load tests of the complete web application confirm this. In more complex tests, the optimisation capabilities of EF such as lazy-loading can offer yet greater performance advantages over Subsonic.

If you compare individual data access operations, e.g. in a simple unit test, Subsonic appears to be faster. In particular, Subsonic initialised more quickly.

I would recommend Fluent NHibernate or Entity Framework if performance is a key consideration.

like image 40
Tim Avatar answered Sep 23 '22 21:09

Tim