Can EntityHistory track properties across DbContexts?
See original GitHub issueDocumentation
Please check the official documentation before asking questions: https://aspnetboilerplate.com/Pages/Documents
GitHub Issues
GitHub issues are for bug reports, feature requests and other discussions about the framework.
If you’re creating a bug/problem report, please include followings:
- Your Abp package version: 4.11.0 (.netcore 3.0 prevents me from going to 5.0 (damn client side evals…))
- Your base framework: .Net Core.
- Exception message and stack trace if available.
- Steps needed to reproduce the problem.
I have generated a template project and configured to use multiple DbContexts
using an (out of date) sample provided by ABP here.
I’ve followed the docs for implementing entity history and was successfully able to audit PortalDbContext.Users
email property changes. So far so good!
In SecondDbContext
, Table1
inherits from IFullAudited
and I would like to track property changes for this table. I did everything I did with the Users
table to Table1
but I am unable to get any records in EntityPropertyChanges
, EntityChangeSets
or EntityChanges
.
After a few hours of trying a bunch of different things, I decided to move Table1
from SecondDbContext
to PortalDbContext
and after trying again, I finally got some records to show up in the EntityChanges
tables.
It would seem that either tracking Property Changes is not supported on entities NOT on the same DbContexts
as the ‘EntityChanges’ table OR there is additional configurations required that not in the docs.
I am working on attaching a reproducible project. May need an hour to split into a separate project.
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (7 by maintainers)
Top GitHub Comments
@multinerd does your second dbcontext inherits from
AbpZeroCommonDbContext
?Otherwise, you will need to either
IEntityHistoryStore
to save entity history intoEntityChanges
table via first dbcontext as mentioned by @malimingEntityChanges
to second dbcontext and invokeIEntityHistoryHelper.CreateEntityChangeSet
andIEntityHistoryHelper.SaveAsync
in your second dbcontext’sSaveChangesAsync
method@multinerd when seeing
Zero
in the context of Abp, it is always referring tomodule zero
, see https://aspnetboilerplate.com/Pages/Documents/Zero/Overall