C#C
C#2y ago
31 replies
pyrodistic

Entity Framework - Circular References

Hey everyone. I'm stuck on this issue since yesterday. I'm using Entity Framework (repository & unit of work), AutoMapper and Blazor. I have a endpoint that retrieves, for example, Teams and that allows me to choose which properties to include. The issue is that I am unable prevent circular references from the entities, even when using mapping, for example, Teams references Persons, Person has a Team, so it references Teams, and so on. I have tried MaxDepth, PreserveReferences on mapping, as well as ignoring cycles on JSON and what seems like dozen other suggestions, ironically I think I'm going in circles.

This seems to me like it's something that MUST have a easy solution, but I'm not being able to find anything on it.

https://paste.mod.gg/nfujgutykvga/0
A tool for sharing your source code with the world!
Was this page helpful?