Error when serializing EF Code First 5.0 data in WebAPI Controller

后端 未结 1 1823
鱼传尺愫
鱼传尺愫 2021-01-05 05:33

I had originally asked this question: How Do I Resolve "A specified Include path is not valid"? which was answered, and my .Include() is now working, however, when

相关标签:
1条回答
  • 2021-01-05 06:11

    In order to fix this I needed to:

    1. Disable lazy loading, and
    2. Use the IgnoreDataMember from System.Runtime.Serialization as an attribute on the Category navigation property (the back-reference on the Product class).

    Hope this helps someone.

    To get around the XML-ish errors I used help from here: http://www.strathweb.com/2012/03/serializing-entity-framework-objects-to-json-in-asp-net-web-api/

    To get around the problem with the cyclic references, I used this as a guide: MVC 4, Upshot entities cyclic references

    0 讨论(0)
提交回复
热议问题