Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Entity Framework or something else? [closed]

I am just switching from C to C# and would like to invest sometime learning database work. I am overwhelmed with the options: Linq-to-sql, ADO.NET. nHibernate, EntityFramework, plain old sql (I am used to this). Since I have only limited 'learning' hours available (about 2.5 hours per day), where should I invest my time?

I don't want to learn something that will be obsolete next month or for which no one will hire me.

If I learn EF, will this knowledge be easily transferrable to nHibernate?

Update: I decided to start with nHibernate. While EF 4.0 has fixed many shortcomings, I don't have VS2010 right now and won;t have it for another 1 year. So nHibernate is the man for now.

like image 328
RonJ Avatar asked Dec 12 '22 21:12

RonJ


2 Answers

Personally, I think NHibernate (plus FluentNHibernate and Linq to NHibernate) lets me keep the most sanity. In real world projects, managing a single EDMX file for a large data model in Entity Framework is really painful across a large team; in NHibernate, Fluent lets you separate things across multiple C# files, or the HBM xml format allows you do use multiple XML files. The last time I used the Entity Framework, that wasn't easy unless you had separate DataContexts for each model. (If that's changed in some way recently, I apologize for my ignorance). The most difficult thing about NHibernate will probably bite you in most ORM tools in one way or another: mapping object graphs to relational models is tricky. But you get an awful lot of control over things like lazy loading, parent/child relationships, and so on; mapping by convention is also a huge win if you're using Fluent.

But you won't go broke picking the tool that Microsoft is investing in; a lot of companies didn't even seriously consider using an ORM until the Entity Framework was released. Personally, I don't really want to work for companies that defer decisions like this until their vendor finds a passable solution, but the fact is, a lot of companies do (or will) use the Entity Framework.

There's absolutely nothing wrong with using the Entity Framework, although I suspect that if you used EF in anger for a real-world project for 4 weeks, and NHibernate in anger for about 4 weeks, with multiple developers on the project, there's a good chance you'd find NHibernate simpler. In my experience, EF looks much simpler at first, but gets hairier the longer you use it. NHibernate looks and feels much harder at first, but gets simpler and more obvious the longer you use it.

like image 194
JasonTrue Avatar answered Jan 09 '23 02:01

JasonTrue


Rather than pick something you think you might be hired for, focus on EF (perhaps) as a concrete example of a solution to the ORM problem as a whole. In spite of leaning EF your future employer might be an nHibernate house, or have their own home-grown solution. Learn EF, but use that experience to learn the ins and outs of ORM.

like image 31
n8wrl Avatar answered Jan 09 '23 03:01

n8wrl