I'm using ASP.NET Web API with Entity Framework but i'm facing a problem while generating the JSON for the navigation property:
I have two tables; Product and Category.
public class Product
{
public int ProductID { get; set; }
public string ProductName { get; set; }
public virtual Category Category { get; set; }
}
public class Category
{
public int CategoryID { get; set; }
public string CategoryName { get; set; }
public virtual ICollection<Product> Products { get; set; }
}
when I generate the JSON for Product it generates the JSON category which is fine but inside the Category JSON there is another JSON pointing to JSON product so a huge JSON file is create i tried to solve this issue by removing virtual but every time i update the model i face the same problem. is there any way to solve?