Environment:
- .net 4.6 1.0.0-rc1-update2
- Entity Framework core rc final.
My API controller is throwing this exception:
An unhandled exception was thrown by the application. Newtonsoft.Json.JsonSerializationException: Self referencing loop detected for property 'Site' with type 'Blog.Model.Site'. Path '[0].Menus[0]'.
How can I implement the fixes suggested here: JSON.Net Self referencing loop detected
As far as I know, EF core does not implement lazy loading or proxy creation.
My controller simply returns the collection generated by this query:
public async Task<List<Site>> GetActiveSites()
{
var query = db.Sites.Where(x => x.Active)
.Include(x => x.Menus)
.ThenInclude(m => m.MenuContentItems)
.ThenInclude(x => x.ContentItem);
return await query.ToListAsync();
}
Where:
- Site(1) - Menu(*)
- Menu(1) - MenuontentItem(*)
- MenuContentItem(*) - ContentItem(1)