Cycling problem

Atilla Rüstəmli 20 Reputation points
2024-07-16T19:06:27.2733333+00:00

Hi, I have 2 entity which have one to many relation between. Lets name them School and student. When I'm creating School I'm getting cycling problem . I did all the configuration in Configure class but nothing worked. There is a way with [JsonIgnore] but I don't think it is the best way of it.

Entity Framework Core
Entity Framework Core
A lightweight, extensible, open-source, and cross-platform version of the Entity Framework data access technology.
723 questions
ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,371 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Michael Taylor 50,996 Reputation points
    2024-07-16T19:39:26.0166667+00:00

    This isn't clear to me. You have a circular dependency issue? What do you mean by cycling problem? Are you getting an error, if so then provide us the error?

    Also provide us sample code to see what you are talking about. At a minimum show us your POCOs that are causing the issue + any entity configurations you're using to map the POCOs to the database. In general the problem is caused by defining relationships on both sets of entities. You should define relationships on only 1 of the entities. EF will handle the bidirectional nature of the relationships.

    0 comments No comments