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);
}
}