Is there any way to track entity changes of an owned entity type? https://learn.microsoft.com/en-us/ef/core/modeling/owned-entities
Currently we don't get PropertyChanges in the following scenario:
Entities:
public class Address
{
public string City { get; set; }
public string PostalCode { get; set; }
public string StreetAndNumber { get; set; }
...
}
[Audited]
public class Company : FullAuditedAggregateRoot<Guid>, IMultiTenant
{
public string Name { get; set; }
public Address Address { get; set; }
...
}
EFCore DbContext config:
public static void ConfigureModule(this ModelBuilder builder)
{
Check.NotNull(builder, nameof(builder));
builder.Entity<Company>(b =>
{
b.ToTable(ModuleDbProperties.DbTablePrefix + "Companies", ModuleDbProperties.DbSchema);
b.ConfigureByConvention();
b.Property(x => x.Name).IsRequired().HasMaxLength(CompanyConsts.NameMaxLength);
b.OwnsOne(
x => x.Address,
b =>
{
b.Property(x => x.City).HasMaxLength(AddressConsts.CityMaxLength);
b.Property(x => x.PostalCode).HasMaxLength(AddressConsts.PostalCodeMaxLength);
b.Property(x => x.StreetAndNumber).HasMaxLength(AddressConsts.StreetAndNumberMaxLength);
});
...
});
}
AuditLog auditLog = await _auditLogRepository.GetAsync(...);
EntityChange entityChange = auditLog.EntityChanges.First();
entityChange.PropertyChanges
When updating the company's name and address details, only a property change for the name is generated, not for the address properties. Do we miss some configuration here or is it not supported (yet)? How can we get property changes for the address information?
Thanks in advance!