[maliming] said: hi
ABP soft delete actual do a update operator. So your
OnDeletewon't be called.You can add an event handler
EntityUpdatedEventData<IdentityUser>and check ifIsDeletedis true or false.Thanks.
Hi,
Thanks for your response on this. We'll look into these options.
Thanks.
Thanks for the clarification.
In our case, the Manager is deleted through the built-in Identity Management → Users page (i.e., the default user deletion flow provided by ABP).
Given that, how can we customize this flow so we can implement the following approach?
Override/customize the user deletion process in our application/domain service and explicitly update dependent entities (e.g., set Employee.ManagerId = null) before or after the user is soft-deleted.
What is the recommended way in ABP to hook into or override the built-in user deletion logic used by the Identity Management module so we can safely apply our custom logic when a user is deleted from the UI?
Hi,
We encountered a scenario where an entity (with its own entity type configuration) contains a nullable reference to IdentityUser.
In the entity configuration, we specified:
.OnDelete(DeleteBehavior.SetNull)
However, when the related IdentityUser is soft deleted, the reference is not updated to null. As a result, the entity continues to reference a soft-deleted IdentityUser, effectively creating a broken reference.
We are currently using ABP.IO version 9.3.2 (commercial license).
Our expectation was that ABP’s soft delete mechanism would also honor OnDelete(DeleteBehavior.SetNull) and automatically set the foreign key to null. However, this does not seem to be happening.
Could you please confirm whether ABP.IO handles soft delete scenarios together with OnDelete(DeleteBehavior.SetNull)? If it does, could you clarify how to achieve the expected behavior?
See below code as an example:
public class Employee : FullAuditedEntity<int>
{
public Guid? ManagerId { get; set; }
[ForeignKey(nameof(ManagerId))]
public IdentityUser? IdentityUser { get; set; }
public Employee()
{
}
}
public sealed class EmployeeConfig : IEntityTypeConfiguration<Employee>
{
public void Configure(EntityTypeBuilder<Employee> builder)
{
builder.ToTable(FfWConsts.DbTablePrefix + "Employees", FfWConsts.DbSchema);
builder.ConfigureByConvention();
builder.HasOne(p => p.IdentityUser).WithMany().HasForeignKey(x => x.ManagerId).OnDelete(DeleteBehavior.SetNull);
}
}