Code inspection: The relationship defined by this property contributes to a dependency loop
This inspection reports dependent relationship between the classes used in the context of Entity Framework. In the example below, a bidirectional relationship between Person
and Animal
forms a cycle: a Person
has Pets
(of type Animal
), and each Animal
has an Owner
(of type Person
):
public class Person
{
public int Id { get; set; }
public IList<Animal> Pets { get; }
}
public class Animal
{
public int Id { get; set; }
public Person Owner { get; set; }
}
public class Location
{
public IList<Person> Clients { get; }
public IList<Animal> Pets { get; }
}
Last modified: 26 May 2024