Problems with the WCF Datacontract serialization of circular reference in Entity Framework

1.9k views Asked by At

I am using Entity Framework 4, having the circular reference among some of entities, but I am getting stackoverflow exception, this is the scenario when lazy loading is enabled...

Then I have made lazy loading enabled as false and include all the related entities using Include() method but still am getting the same error... Help needed....

2

There are 2 answers

4
Dave Lawrence On

I came across this before - I solved it by adding the [IgnoreDataMember] attribute to the property causing the circular reference. This was usually the navigation property that referenced the parent entity.

1
Olav Nybø On

If you can't remove your cycles then something like WCF cyclic references should fix it