Base solution for your next web application
Open Closed

Add a new property to History related table #8516


User avatar
0
ptaylor created

Product type: ASP.NET Core + Angular Version: 7.0.0

I have a requirement to add a new property to History related table, AbpEntityChange to be precise. I am able to do this by following Extending Existing Entities. I just couldn't find the file where I can modify the newly added property i.e. I want to modify or add value to this property when a new entity of AbpEntityChange is created.

Please let me know the area where these changes are currently being made in my application.

Thanks


3 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @ptaylor

    You can define your own EntityHistoryHelper class which inherits from https://github.com/aspnetboilerplate/aspnetboilerplate/blob/dev/src/Abp.ZeroCore.EntityFrameworkCore/EntityHistory/EntityHistoryHelper.cs and replace your implementation with default one in dependency injection using code below in your EF Core module's PreInitialize method;

    Configuration.ReplaceService<IEntityHistoryHelper, MyEntityHistoryHelper>();

    Than, youy can override any method in your MyEntityHistoryHelper class and set necessary properties you want.

  • User Avatar
    0
    ptaylor created

    Thanks for your reply @ismcagdas.

    There is some followup questions against your reply:

    1. Do we have to upgrade from v7.0.0 to the latest verision?
    2. In our version, the file EntityHistoryHelper is in MyProject.Core rather than MyProject.EntityFrameworkCore and also there is a very little code in my current EntityHistoryHelper. And our app couldn't even find EntityHistoryHelperBase to extend from.

    Please help.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    1. You don't have to upgrade AspNet Zero but you need to upgrade ABP NuGet packages.
    2. Sorry, you can place it in Core project. https://github.com/aspnetboilerplate/aspnetboilerplate/blob/dev/src/Abp/EntityHistory/EntityHistoryHelperBase.cs added recently. If you upgrade ABP NuGet packages, you can use it.