I am trying to decide the pros and cons of the 2 ORM primarily in this area.
- Compatibility with Sql Server 2008 R2 & 2012.
- This is very important as we simply don't have the resources to debug poor support of existing MS technology stack.
- Also planning ahead since 2012 is pretty much out and plans to migrate to it are in place.
- Support for .NET 4.0 and 4.5 (upcoming)
- Again very important for pretty much the same reason above.
- Transaction handling and table hints eg. forcescan forceseek, read uncomitted.
- A lot of times the query optimizer does its job well, other times I want the flexibility to tell it what to do.
- Support for conversation, self tracking attach & detach
- This is somewhat fundamental. I hate to keep the session open for prolonged period. Especially in distributed computing/web farm environment.
- Ability to handle code first development, create and update schema without destroying data.
- EF 4.1 seems to be wanting in this regard, although 4.3 is leap and bound better. Also liking the data annotation better than seperate mapping classes in NH. Reason being I want to be able to send in the class and from there be able to create persistence model without widening the method for the mapping classes.
- Support for IRepository pattern
- Support for LINQ
- Somewhat tied to (6) above I want really good support for linq. I don't want developers to muck around with lower level implementation and getting ourselves stuck to one particular ORM
- Performance
- Support for bulk CRUD operations, without having to load the data into the application layer. Eg. I want to increment all rows in a column of a particular table by 1. I don't want to load this up to memory, and increment the rows one by one. This would be crazy for such a simple operation. Linq2Sql used to have Magiq to handle this sort of thing, what does NH and EF have?
- Caching, eager loading, lazy loading, navigation properties.
- Let me be frank I hate these things when done implicitly. Reason being it's hard to distinguish what is cached, stale from what is new. In EF I usually drop all navigation properties, because I don't want these properties loaded with top 5, because that's what the current operation needs, but further down the stream another developer attempts to do a count which will be inaccurate.
- So my personal policy - all SOA shall be stateless unless there is a good reason otherwise. If you need referencing data, get it from persistence. It will be slower but the code will be more readable and flexible.
- Similarly for caching. It is complex enough as it is in distributed environment, I want all caching to be very very explicit. If a developer wants to code against the cache, it should do so, not code against the ORM, and make it appear as if he is pulling fresh data from persistence when in fact he is getting stale data.
- Now question is, does NHibernate have any concept/abstraction that would make caching, eager/lazy loading so much more explicit than the one currently available in EF. In this case I don't care much about ease of development, I care more about clarity and explicitness.
Also I don't care much for OSS vs. propietary argument. The team cannot afford the time to peek under the hood and start messing around with other people's code. I care more about the "it just works" angle than anything else.