In my web api when i run project for get data from database got this error .net core 3.1
JsonException: A possible object cycle was detected which is not
following code is working for me in dotnet 5.0 :
services.AddControllersWithViews() .AddJsonOptions(o => o.JsonSerializerOptions .ReferenceHandler = ReferenceHandler.Preserve);