Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I had this problem and solved it by adding the Newtonsoft.Json.JsonIgnoreAttribute to the property causing the loop. Obviously, that property won't be serialized. To help with this problem, I typically will have both the foreign reference ID and the foreign class in my entities. I realize this is not intuitive (or super great OO), but it is the way recommended by Julia Lerman in her book Programming Entity Framework: Code First. I've found it helps smooth out several problems with Entity Framework.</p> <pre><code> public class SomeEntity { [JsonIgnore] public ForeignEntity SomeForeignEntity {get;set;} public Guid ForeignEntityId {get;set;} } </code></pre> <p>Update: I forgot to mention I also needed to disable proxies on the DbContext like so:</p> <pre><code>dataContext.Configuration.ProxyCreationEnabled = false; </code></pre> <p>If you are writing the code for a service (which seems likely if you are serializing), then this is probably not a problem, but there are some things you lose when the proxy creation is disabled. See here: <a href="http://www.sellsbrothers.com/posts/Details/12665" rel="nofollow">http://www.sellsbrothers.com/posts/Details/12665</a> for more details.</p> <p>I am using the MS Web Api, so I just disable the the proxy creation when I construct my controller:</p> <pre><code>public class MailingApiController : ApiController { public MailingApiController() { PreventDeepSerialization(); } private static void PreventDeepSerialization() { var dataContext = Injector.Get&lt;IIntertwyneDbContext&gt;(); dataContext.Configuration.ProxyCreationEnabled = false; } .... </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload