JSON.NET Error Self referencing loop detected for type

后端 未结 25 2958
我在风中等你
我在风中等你 2020-11-22 02:16

I tried to serialize POCO class that was automatically generated from Entity Data Model .edmx and when I used

JsonConvert.SerializeObject 

25条回答
  •  梦毁少年i
    2020-11-22 02:31

    For .NET Core 3.0, update the Startup.cs class as shown below.

    public void ConfigureServices(IServiceCollection services)
    {
    ...
    
    services.AddControllers()
        .AddNewtonsoftJson(
            options => options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore
        );
    
    ...
    }
    

    See: https://devblogs.microsoft.com/aspnet/asp-net-core-updates-in-net-core-3-0-preview-5/

提交回复
热议问题