Pages

Wednesday, August 9, 2017

Self Referencing Loop Detected - Entity Framework

Error received:
self referencing loop detected for propert with type System.data.entity.dynamic.proxiesOccurs when trying to serialize the EF object collection directly.Some ways correcting:

Add to the db context constructor:

Configuration.ProxyCreationEnabled = false;

Or (better way),

HttpConfiguration config = GlobalConfiguration.Configuration;

config.Formatters.JsonFormatter
            .SerializerSettings
            .ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore

Other ways of correcting found at Stackoverflow

This post is for the purpose of my notes only and sometimes a rant.

“I invented nothing new. I simply assembled the discoveries of other men behind whom were centuries of work. Had I worked fifty or ten or even five years before, I would have failed. So it is with every new thing. Progress happens when all the factors that make for it are ready and then it is inevitable. To teach that a comparatively few men are responsible for the greatest forward steps of mankind is the worst sort of nonsense.”
Henry Ford

1 comment:

  1. Hello there I am so grateful I found your blog page, I really found you by accident, while I was browsing on Aol for something else, Nonetheless I am here now and would just like to say thank you for a incredible post and a all round entertaining blog (I also love the theme/design), I don’t have time to browse it all at the moment but I have book-marked it and also added your RSS feeds, so when I have time I will be back to read a lot more, Please do keep up the awesome work. yahoo login

    ReplyDelete