I have been trying to build a CMS using .NET Core 2.1 with a feature to stage web content changes, therefore I have three sites in my system architecture:
- CMS Site - User could propose changes to web content through the CMS, and the changes will be pushed to the Staging/Production Site after being approved by admin.
- Staging Frontend - The frontend web for internal UAT purposes, displays all approved/unapproved web content.
- Production Frontend - The frontend web facing the public, displays only approved web content.
I have three DbContext
instances injected for achieving the above:
CmsContext
- Stores first-round web content changes proposed by a user.StagingContext
- Where the staging web frontend reads web contentProductionContext
- Where the production web frontend reads web content
The problem I encountered was, when I try to do the following (with lazy-loading enabled):
var entity = await stagingContext.FindAsync(entityType, entityId);
productionContext.Update(entity);
await productionContext.SaveChangesAsync();
navigation properties are not updated as what I have expected.
I have also tried the ChangeTracker.TrachGraph
approach, but it does not iterate through navigation properties.
I understand that the reason might be, even though lazy-loading is enabled, the navigation properties are never accessed before, so they are not filled up with values for productionContext
to update.
I have read through the Microsoft Docs before I post this question, but could not figure out the correct way to do this. May I have your kind help on this guys? thanks