Tuesday 1 May 2012

Entity Framework POCO class in WCF

I encountered the following error when I tried to use generated POCO classes with WCF service:

Failed to invoke the service. Possible causes: The service is offline or inaccessible; the client-side configuration does not match the proxy


My POCO classes already have DataContract&DataMember attributes applied.

The problem is that by default, entity framework dynamically generates proxy class whenever a instance of entity type is created. The entity type returned from or passed into the WCF service is actually a proxy object.

The fix is really simple, just turn off proxy object generation by setting
Configuration.ProxyCreationEnabled = false

No comments:

Post a Comment