无法在ASP.NET零中启用实体历史记录 [英] Can't enable Entity History in ASP.NET Zero

查看:163
本文介绍了无法在ASP.NET零中启用实体历史记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用ASP.NET Zero.项目版本: 5.1.0 和.NET Core 2.0模板.我正在尝试为我的实体启用实体历史记录",以便可以看到表的已删除列和旧列值.

I'm using ASP.NET Zero. Project Version: 5.1.0 and .NET Core 2.0 template. I'm trying to enable Entity History for my entity so that I can see the deleted and old column values for the table.

实体类:

[Table("TestingEntity")]
[Audited]
public class TestingEntity : AuditedEntity , IMayHaveTenant
{
    public int? TenantId { get; set; }

    public virtual string Code { get; set; }
}

ApplicationModule类:

public class MyCompanyApplicationModule : AbpModule
{
    public override void PreInitialize()
    {
        // ...

        Configuration.EntityHistory.IsEnabledForAnonymousUsers = true;

        Configuration.EntityHistory.Selectors.Add(new NamedTypeSelector("Abp.AuditedEntities", type => typeof(IAudited).IsAssignableFrom(type)));
    }

    // ...
}

运行以下查询不会产生任何结果.

Running the following queries give no results.

SELECT * FROM [AbpEntityChangeSets]
SELECT * FROM [AbpEntityPropertyChanges]
SELECT * from [AbpEntityChanges]

参考: https://aspnetboilerplate.com/Pages/文档/实体历史记录

当我删除一个实体项目时,它没有给出正确的结果.

It is not giving proper results when I'm deleting an entity item.

它正在为每个属性插入记录,这些记录的旧值和新值与 [AbpEntityPropertyChanges] 表中的值相同.

It's inserting records for each property with old and new values the same in [AbpEntityPropertyChanges] table.

并且没有明确的信息表明该实体项已被删除,其删除时间和DeletedBy.

And there is no clear information that this entity item is deleted, its deletion time, and DeletedBy.

这是由于在我的实体类中使用 AuditedEntity 吗?我正在使用硬删除,因此我想不要将这些列添加到表中:被删除,删除时间和DeletedBy.

Is this due to using AuditedEntity in my entity class? I'm using hard delete, so I thought not to add these columns to the table: is deleted, its deletion time, and DeletedBy.

推荐答案

在ASP.NET零中禁用了实体历史记录.您可以启用它:

Entity History is disabled in ASP.NET Zero. You can enable it:

Configuration.EntityHistory.IsEnabled = true;

更新

当我删除一个实体项目时,它没有给出正确的结果.

It is not giving proper results when I'm deleting an entity item.

它正在为每个属性插入记录,这些记录的旧值和新值与 [AbpEntityPropertyChanges] 表中的值相同.

It's inserting records for each property with old and new values the same in [AbpEntityPropertyChanges] table.

已在PR #2977 中解决,该问题将与ABP一起发布v3.5.

That has been resolved in PR #2977, which will be released with ABP v3.5.

并且没有明确的信息表明该实体项已被删除,其删除时间和DeletedBy.

And there is no clear information that this entity item is deleted, its deletion time, and DeletedBy.

这是由于在我的实体类中使用 AuditedEntity 吗?我正在使用硬删除,因此我想不要将这些列添加到表中:被删除,删除时间和DeletedBy.

Is this due to using AuditedEntity in my entity class? I'm using hard delete, so I thought not to add these columns to the table: is deleted, its deletion time, and DeletedBy.

您不会在 AbpEntityPropertyChanges 表中找到这些,因为这些不是属性更改.

You won't find those in AbpEntityPropertyChanges table, since those aren't property changes.

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆