ASP.NET Core API only returning first result of list

Add this to Startup.cs inside the public void ConfigureServices(IServiceCollection services) method:

services.AddMvc().AddJsonOptions(options => {
            options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
        });

The issue was discussed https://github.com/aspnet/Mvc/issues/4160 and https://github.com/aspnet/EntityFramework/issues/4646 also see circular reference

Leave a Comment