locked
Entity data Model serialize Error Self referencing loop detected for type when Serialize RRS feed

  • Question

  • Hi all, Please help me solve my problem, i try to serialize POCO class that automatic generate from Enity Data Model .edmx and when i used JsonConvert.SerializeObject Error Self referencing loop detected for type System.data.entity occurs . How to solve it ? Any ideas ? Thanks in advance !
    Tuesday, September 13, 2011 10:37 AM

Answers

  • Ne7ven,

    Before you generate your object from EF, you need to set a property on your context object so that proxy objects are not created in addition to the POCO object, otherwise you object will not be able to be able to be serialized.

    In order to do that,  on your ObjectContext instance, set a property called ProxyCreationEnabled to False.  Like this:

    MyContextEntities.ContextOptions.ProxyCreationEnabled = false;
    
    
    
    

    Hopefully that will do the trick. 
     


    Tom Overton
    • Marked as answer by Jackie-Sun Monday, September 26, 2011 6:27 AM
    Tuesday, September 13, 2011 12:51 PM