My project is Web Api Core 5.0 and i have got problems with self reference loop EntityFrameworkCore
In my last project i have used this:
services.AddControllers().AddNewtonsoftJson(options =>
options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore);
but on my current version .Net core it's not working, i found something like this:
services.AddMvc().AddJsonOptions(options =>
{
options.JsonSerializerOptions.ReferenceHandler = ReferenceHandler.Preserve;
});
but I dont like it, it shows $Id and $value on response, which i dont want to see Is there another way of the way get rid of that self reference loop?
I read before: JSON.NET Error Self referencing loop detected for type
and these don't help me