'Entity Framework 6 unable to update related models

I have list of models that are attached to a product model, insert is working, but when updated Entity is only updating the product model and ignoring the related models.

Sample code for update:

using (var context = new DemoContext())
{
    context.Entry(pr).State = EntityState.Modified;
    context.Entry(pr.Defaultvatrate).State EntityState.Modified;
    context.Entry(pr.DefaultCat).State = EntityState.Modified;
    context.Entry(pr.DefaultSubCat).State = EntityState.Modified;
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source