WCF Data Services 4 Vs NHibernate

We recently were considering using WCF Data Services (Entity Framework) as our Service Layer.
We did a comparative study of WCF Data Service using EF 4 Vs. Building a service layer with NHibernate as ORM.

Limitations of WCF Data Services and EF:

  1. There is no built in support for Id generation strategy. Supports only assigned ids and identity column. Can do custom Id generation (like HiLo) via stored proc and service interceptor. This is not elegant but workable.

  2. There are no Cascade options. WCF Data Services works with one entity at a time. EF cascades all (i.e. Save assumes all child entities are new and tries to save them).

  3. No support for Readonly properties or foreign keys.(This can be achieved by resetting to old values in the interceptor though).

  4. Does not support unmapped base objects. (So cant have base class like Entity with common properties)

  5. New/Old object and Stale Object check (No built in support. Have to do it in interceptors).

  6. Transaction (No built in support. There is a workaround by using TransactionScope in the interceptor. Again the code will soon become unwieldy).

  7. Multiple object can be saved by setting save option as Batch. This is severely restrictive because the inteceptors are Entity based. So cannot do different actions based on Business Logic.

  8. Exposes both foreign keys and the reference object. Will lead to confusion on the client what to send and not to send.

  9. EF auto generated check for not null, but doesnt understand DB Defaults. Cannot conditionally switch off the validations.

  10. Custom properties added in partial class are not transmitted in WCF Data Service (Everything that is exposed has to be backed by DB).

  11. No support for StatelessSession (Cant optimize code for Batch operations).

  12. No support for entity versioning in detached mode. (e.g. Via Version column or TimeStamp column)

  13. Be careful of foreigns keys. All of them are mapped as collections in the referenced entity. (e.g. If you have Address and AddressType then mapping for AddressType will have a property for All Addresses of that type)

Better:

  1. Support for LINQ in Entity Framework is better.

Almost Equal:

  1. Basic CRUD
  2. Transaction (More or less)
  3. Auditing (Both EF and NH have issues with collections auditing)
  4. Inheritance of types (Like RetailCustomer and CorporateCustomer objects backed by same table Customers).