I really struggled with the title on this one so hopefully I will describe it much better here!
We use Entity Framework as our ORM and Ninject as our Dependency Injection framework. We bind our DbFactory and UnitOfWork as a singleton with Ninject
Bind<IDbFactory>().To<DbFactory>().InSingletonScope();
Bind<IUnitOfWork>().To<UnitOfWork>().InSingletonScope();
Now, within the MVC project this works great but we also want to use an API to post some data back to the server and then refresh the page. It takes around 10 minutes for EF to decide that it wants to query the database again to retrieve the data.
Other than disabling caching, my only theory to this is Ninject is creating an object for the MVC project to use and another for the API. So my question; is my theory correct and if so, how can I overcome this?
Edit: Example model
public class Property
{
public int Id { get; set; }
public virtual ICollection<PropertyPhoto> PropertyPhotos { get; set; }
// Blah blah everything else
}
public class PropertyPhoto
{
public int Id { get; set; }
// Blah blah everything else
}
Now, the API is updating the PropertyPhoto
model through its repository whereas the mvc project is using the Property
model