Base solution for your next web application
Open Closed

Custom Entity History Didn't Work for Multiple Databases #7157


User avatar
0
MellowoodMedical created

We are using multiple databases for the our project. Now we have created a custom implementation for IEntityHistoryStore and used it to replace the default implementation. Also, we have uncommented lines to write change logs for the entities and added the entity type for Entity History selectors. The problem is that Entity History works for entities stored in the one database and doesn't work for entities stored in another databases. Do you have any suggestions for that?

The version of Asp.net Zero is v6.6.0 and we are using EntityFramework Core.


4 Answer(s)
  • User Avatar
    0
    ryancyq created
    Support Team

    Hi, do you mean the entities of another database do not have entity history?

    Can you explain how were the multiple databases implemented? Are they being implemented as different DbContext?

  • User Avatar
    0
    MellowoodMedical created

    Hi,

    We have 2 databases and 2 dbContext and each has its own entities. The one which was created by default with aspnetzero works fine with EntityHistory and the one we added as second database is having issues.

    thanks

  • User Avatar
    0
    ryancyq created
    Support Team

    Hi, was the second db context inherit from AbpZeroCommonDbContext?

    if not, you will have to override the SaveChanges method and call EnityHistoryHelper yourself.

    See https://github.com/aspnetboilerplate/aspnetboilerplate/blob/c8123513d66cec6788cd90871c5ced68be21b861/src/Abp.ZeroCore.EntityFrameworkCore/Zero/EntityFrameworkCore/AbpZeroCommonDbContext.cs#L155-L178

  • User Avatar
    0
    MellowoodMedical created

    Thanks a lot, ryancyq. Your solution works. Our second db context is just inherited from AbpDbContext.