A lot has been talked about Entity Framework first version on the web (also on stackoverflow) and it is clear that it was not a good choice when we already have better alternative like NHibernate. But I can't find a good comparison of Entity Framework 4 and NHibernate. We can say that today NHibernate is the leader among all .NET ORMs, but can we expect Entity Framework 4 to displace NHibernate from this position. I think if Microsoft has really injected very good features in EF4 it can give good competition to NHibernate as it has Visual Studio integration, easier to work with and preference is always given to MS products in most shops.
EF4 has an out-the-box answer with regard to n-tier development, in "self-tracking entities". Nobody has released comparable code for NHib.
NHib has many features that have not been mentioned as being part of EF4. These include the second-level cache integration. It also has greater flexibility in inheritance mapping, better integration with stored procs / database functions / custom SQL / triggers, support for formula properties and so on. IMO it's basically just more mature as an ORM.
Update: I haven't used Entity Framework since version 4.0, so my answer can be outdated. I'm still using NH or pure ADO .NET in my projects. And I don't even want to look at what's new in EF since 4.0, because NH works perfectly.
Actually is pretty easy to compare them when you have used both. There are some serious limitations with EF4, I can name some which I encountered by my self:
EF4 problems:
Self-Tracking Entities: Many say that Self-tracking entities are cool for N-tier development including the top answer in this thread. Thought I haven't even give them a try, I can say they are not.Every input can be forged, you can't simply take the changes that user sends you and apply them to data base, why not give the user direct data base access then? Any way you will have to load the data user is about to change from DB, check that it exist|not exists do permissions checks etc etc. You can't trust user on the state of entity he is sending to server, you will anyway have to load this entity from DB and determine it's state and other things, so this information is useless, as do Self-Tracking entities unless you do a private trusted n-tier system for internal use, in which case maybe you could give just plain DB access. (Thats my thoughts about ST Entities and N-tire, I'm not very expericned in N-Tier, so it can change, if I misunderstood something here comment it)
Logging, Events, integrating business logic: EF4 is like black box, it do something and you have no idea what it do. There is only one event OnSavingChanges where you can put some business logic you need to run before something happens with DB, and if you need to apply some changes to business objects before something happens you will have to dig in ObjectStateManager, and this is really ugly, code can become huge. If you for example using Repository pattern and what to be notified on changes made to DB in clean object way, you will have hard time doing this with EF.
Extensibility: All EF code is private and internal, if you don't like something (and you will not like a LOT if you are serious about EF using), no way you will change this in easy way, In fact I'm sure it's easer to write you own ORM from scratch (I did) then make EF work as you need. As example take a look at EFExtensions source, it's based on extensions methods, and different "hacks" to make EF little more usable, and the code is pretty ugly (and it's not authors fault, when everything in EF is private this is the only way to extend it).
I can continue to write bad things about EF and how painful it was for me to work with it for like 20 pages, and maybe I will.
What about NHibernate? It's absolutely different level, it's like comparing PHP to C#, EF4 is like in Stone-age, it's like EF is 10 years behind then NHibernate in development progress, and in fact it is, Hibernate was started in 2001. If you have free time to learn and switch on Nhibernate, do it.
Here's the thing. NHibernate and Entity Framework are really for two different audiences, in my mind. NHibernate would be my choice in building a system with complex mappings, formulas, and constraints (basically anything enterprise). If I wanted to hit-the-ground running with simple data access, I would use Entity Framework or LINQ-to-SQL. NHibernate doesn't have a clear "drag-and-drop" experience quite like EF. Both have their strengths and drawbacks. Comparing them apples-to-apples, frankly, gets you nowhere.
If you think you might ever want to run your code on Mono, NHibernate is probably a better choice no matter what the feature checklists say...
Edit, 8/13/2012:
Entity Framework has been open-sourced, and is now included in Mono as of 2.11.3. This answer is now outdated and should not be relied upon.
http://weblogs.asp.net/scottgu/archive/2012/07/19/entity-framework-and-open-source.aspx
My take on this is that EF4.0 has came a long way since 1.0 and is catching up to Nhibernate in functionality, but it's not all there yet.
However it is Microsoft, out of the box, and do 100% of what 95% of applications need it to do. However, NHibernate has been doing the same thing for years. Come version 5.0 or 6.0 may catch up, or even surpass NHibernate.
Here is my advice -- if you have time to learn both, then do it. There are several reasons to choose one over the other. If you are writing code for a corporation, it is realistic to expect to be able employees who would be familiar with EF, as it's in all the books and what kids learn in college. If EF will meet your requirements (think about this one long and hard before just saying yes), then it's a perfectly fine solution for now, and in a few years it may (ok, most likely will) surpass NHibernate.
NHibernate is a very mature product with a few years on EF and will most likely do everything you would ever want to do and then some. It has been the best ORM for a while now and a lot of people use it.
I think the fact that EF 4 will have the ability to use POCO and deferred lazy loading will be very big. I could definitely see it gaining traction with the new release.
There is an obvious trend [1] of increasing EF popularity over NHibernate, see the picture.
[1] http://www.google.com/trends/explore#q=entity%20framework,%20nhibernate&cmpt=qMy 2 cents: we use ef on our desktop client for some cahing etc - no hi loads. An NHib on server side - utilizing Stateless sessions, hilo id generation and batches. Is is quite fast in inserting 3k+messages in db per second. Also it is very flexible and supports lots of dbs, wich is crucial for our product.
Mapping directly to stored procedures with a combination of Linq for a logical layer seems the easiest approach. No xml. Generate sql only for interesting queries that are less frequently used or not suitable for stored procedures.
Objects load and store through standard SPs. This approach allows the use of two sql logins. One for the class access through SPs (execute-only permissions) and one for a logical linq module that allows direct table access.
Choosing between ORM's by popularity isn't the best thing to do. I've tried to move to EF the past 2years and all I can say is, why the hell I still try to?
ATM my point of view about EF is: "It's made for really small pretty tiny bit systems with no more than 3 tables with less than 1 relationship (0 is better)".
And why do I think like that? 1. Try to update a disconnected graph and see your model scratch;
Try to make TPH with deep inherited trees and you'll find you that you are schackled to a single hierarchy or the system will break.
Try to make more cumbersome queries and watch the whole system eat out the stack :D... overflows happen very often.
Map XML datatypes is based on extensions or the most "hated" NotMapped properties... and it's even worse.
Try mixing SQL query into Linq for more finner queries and you'll break the wall lol.
And the last and most important thing, EF doesn't support property formula ('an awesome resources NH has for legacy databases'), and doesn't support complex type mappings for same table and related tables.
That's my 10cc.