The EF audit events are stored using a data provider. You can use one of the available data providers or implement your own. This can be set per the DbContext
instance or globally. If you plan to store the audit logs with EF, you can use the Entity Framework Data Provider.
You can configure the following settings globally or you can also configure them for each context class.
The Mode indicates the audit operation mode, which contains the following two options.
All the entities are tracked by default, except those explicitly ignored. (Default)
No entity is tracked by default, except those explicitly included.
The IncludeEntityObjects
indicates if the output should contain the complete entity object graphs. Its default value is false
.
The AuditEventType
indicates the event type to use on the audit event. It contains the following placeholders:
{context}
: You will need to replace it with the DbContext
type name.{database}
: You will need to replace it with the database name.The IncludeIndependantAssociations
indicates if the independent associations should be included or not. The default value is false
and it is only for EF <= 6.2.
The ExcludeTransactionId
indicates if the Transaction IDs should be excluded from the output and not be retrieved. The default value is false
to include the Transaction IDs.
The ExcludeValidationResults
indicates if the entity validations should be avoided and excluded from the audit output. The default value is false
.
The EarlySavingAudit
indicates if the audit event should be saved before the entity saving operation takes place. The default is false
to save the audit event after the entity saving operation completes or fails.
You can configure the following settings per entity type.
The IgnoredProperties
indicates the entity's properties (columns) to be ignored on the audit logs.
The OverrideProperties
indicates constant values to override properties on the audit logs.
The FormatProperties
indicates replacement functions for the property's values on the audit logs.