Auditing EF8 Core Complex Properties #697
-
I am a new user of Audit.EntityFramework.Core. I am auditing quite a simple database using AuditTypeNameMapper and mostly everything is working really well. I have a few complex properties (e.g. a struct with X and Y properties) and while I can see these in the EntityFrameworkEvent separated out into their generated column names (e.g. Element_X and Element_Y), they do not get copied automatically into the matching audit record. Is this a limitation of the column matching? If so is there a better way to handle this type of property? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
I assume you're referring to an audit log entity where the column names of complex properties correspond directly to the audit entity properties. [ComplexType]
class Element
{
public int X { get; set; }
public int Y { get; set; }
}
// Entity to audit
class Foo
{
[Key]
public int Id { get; set; }
public string Name { get; set; }
public Element Element { get; set; }
}
// Audit entity with 'matching' properties
class FooAuditLog
{
[Key]
public int AuditId { get; set; }
public string Name { get; set; }
[Required]
public Element Element { get; set; } // <--- Is this what you're asking about?
} If that's what you're referring to, then yes, currently the library will not automatically match complex properties. This line only returns scalar properties, excluding complex ones. I'll examine this further, as I believe the issue can be fixed by adding the mapping of the complex properties from the entity to the audit entity. |
Beta Was this translation helpful? Give feedback.
-
This was fixed in version 27.0.3. Kindly update your references to the latest version and re-test. If the issue persists, feel free to leave a comment below |
Beta Was this translation helpful? Give feedback.
This was fixed in version 27.0.3. Kindly update your references to the latest version and re-test. If the issue persists, feel free to leave a comment below