.Net Core 3.0 possible object cycle was detected which is not supported

前端 未结 8 1649
我寻月下人不归
我寻月下人不归 2020-12-02 09:27

I have 2 entities that are related as one to many

public class Restaurant {
   public int RestaurantId {get;set;}
   public string Name {get;set;}
   public          


        
相关标签:
8条回答
  • 2020-12-02 10:28

    Who are still facing this issue: check if you await-ed all async methods.

    0 讨论(0)
  • 2020-12-02 10:33

    I have tried your code in a new project and the second way seems to work well after installing the package Microsoft.AspNetCore.Mvc.NewtonsoftJson firstly for 3.0

    services.AddControllersWithViews()
        .AddNewtonsoftJson(options =>
        options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore
    );
    

    Try with a new project and compare the differences.

    0 讨论(0)
提交回复
热议问题