What you are experiencing here might be caused by two things:
1) Does the entity instance you return have a m:n relationship.
If so, the DataContractSerializer that serializes entities over the wire from the WCF service will go on and on forever since it (be default) has no knowledge of object identity. Meaning, if you reference the same object (same object id and class) twice the xml over the wire will represent the same object twice. In a m:n relationship two classes (A and B) will have a list of objects (for class A it will have a list of class B instances and vice versa) residing in each class. Thus, the serializer goes on and on forever by default.
2) The lazy loading is "activated" during serialization
If an Order has a list of OrderLine instances and you go and fetch the Order and return it from your WCF service the serializer will "activate" lazy load of the OrderLine instances, since they where not loaded when the entity (Order) was originally fetched. So basically the serializer traverses the object graph starting from the Order (or whatever type you return) and produces xml for it to be sent over the wire.
However, there is something to do about it.
If your check this thread
, there's a solution for case 1) and another for case 2)
In general (at least I think so) it is not a good idea to pass your persistent entities over the wire for the reasons mentioned in the referenced thread. If you don't mind, maybe you should check out the Telerik Data Services way of doing things.
It is all about, detaching the entity from the persistence context (OpenAccessContext) in this case, so the serializer does not invoke the lazy loading.
Just my two pennies,
PS. That being said.. I know Telerik has something coming up with DTO's (detached business objects) that you can use as a DataContract for your WCF service in a later release...
Can someone from Telerik elaborate on this... is it going into the Q3 or later maybe and can it be used to the above scenario? (to me it looks like it can...although depending on how it is implemented)