I am using entity framework code first approach. I have design POCO classes based on table relation in database like product category and product have one to many relation so category class is being designed as shown below:
public class ProductCategory
{
public int CategoryID { get; set; }
public string Name { get; set; }
public virtual ICollection<Product> Products { get; set; }
}
Now while serializing ProductCategory class object i am having following error "The ObjectContext instance has been disposed and can no longer be used for operations that require a connection."
As per answer i got in stackoverflow this is due to lazy loading and removing lazy loading is the only way to resolve this issue. (ref - System.ObjectDisposedException: The ObjectContext instance has been disposed and can no longer be used for operations that require a connection)
AS PER MY UNDERSTADING "AS EF IS OFTEN USED WITH WEB API LAZY LOADING SHOULD NOT BE AN ISSUE WHILE SERIALIZING"
I can not remove lazy loading as it an existing well tested client project. My task is only to replace old UI with angular JS.
Please provide me if there any alternative solution.
Thanks,
@paul