Cosen
✅ EntityFramework: Navigation property makes a nested object call
So i have transports and categories models/tables , both are connected with a relationship , one category can have many transports and vice versa. Here is my code:
Category model:
Transport model:
The problem is i get this schema in swagger api call:
My category table tries to call another value called "transports" , which i think is from the navigation property in categories model:
The problem fixes itself if i add [JsonIgnore] in my categories model above the navigation line:
but it seems this is a bad practice:
I have tried to dto my Transport model:
but this way it does not return the relationships with category table.
I am kinda lost here , what am i doing wrong?
7 replies