From 96c5c048de1bd8e358a7793b881d6d7e4c4e9b08 Mon Sep 17 00:00:00 2001 From: Smit Patel Date: Tue, 15 Dec 2020 15:18:03 -0800 Subject: [PATCH] Reference 5.0 API using xref Resolves #2748 --- .../core/logging-events-diagnostics/events.md | 6 +++--- .../core/logging-events-diagnostics/index.md | 2 +- .../core/logging-events-diagnostics/interceptors.md | 10 +++++----- .../logging-events-diagnostics/simple-logging.md | 12 ++++++------ entity-framework/core/modeling/inheritance.md | 2 +- entity-framework/core/modeling/relationships.md | 2 +- entity-framework/core/providers/cosmos/index.md | 8 ++++---- .../core/what-is-new/ef-core-5.0/breaking-changes.md | 2 +- .../core/what-is-new/ef-core-5.0/whatsnew.md | 2 +- 9 files changed, 23 insertions(+), 23 deletions(-) diff --git a/entity-framework/core/logging-events-diagnostics/events.md b/entity-framework/core/logging-events-diagnostics/events.md index ac7dfbc6be..a126998e34 100644 --- a/entity-framework/core/logging-events-diagnostics/events.md +++ b/entity-framework/core/logging-events-diagnostics/events.md @@ -21,9 +21,9 @@ The following events are raised by EF Core: | Event | Version introduced | When raised |:------|--------------------|------- -| `DbContext.SavingChanges` | 5.0 | At the start of or -| `DbContext.SavedChanges` | 5.0 | At the end of a successful or -| `DbContext.SaveChangesFailed` | 5.0 | At the end of a failed or +| | 5.0 | At the start of or +| | 5.0 | At the end of a successful or +| | 5.0 | At the end of a failed or | | 2.1 | When an entity is tracked by the context | | 2.1 | When a tracked entity changes its state diff --git a/entity-framework/core/logging-events-diagnostics/index.md b/entity-framework/core/logging-events-diagnostics/index.md index faf51bb839..6b79aad93d 100644 --- a/entity-framework/core/logging-events-diagnostics/index.md +++ b/entity-framework/core/logging-events-diagnostics/index.md @@ -29,7 +29,7 @@ The table below provides a quick reference for the differences between the mecha > [!NOTE] > This feature was introduced in EF Core 5.0. -EF Core logs can be accessed from any type of application through the use of [LogTo](https://github.com/dotnet/efcore/blob/ec3df8fd7e4ea4ebeebfa747619cef37b23ab2c6/src/EFCore/DbContextOptionsBuilder.cs#L135) when [configuring a DbContext instance](xref:core/dbcontext-configuration/index). This configuration is commonly done in an override of . For example: +EF Core logs can be accessed from any type of application through the use of when [configuring a DbContext instance](xref:core/dbcontext-configuration/index). This configuration is commonly done in an override of . For example: interface. As for other interceptors, the `SaveChangesInterceptor` base class with no-op methods is provided as a convenience. + and interception points are defined by the interface. As for other interceptors, the base class with no-op methods is provided as a convenience. > [!TIP] > Interceptors are powerful. However, in many cases it may be easier to override the SaveChanges method or use the [.NET events for SaveChanges](xref:core/logging-events-diagnostics/events) exposed on DbContext. @@ -497,7 +497,7 @@ The general idea for auditing with the interceptor is: * If SaveChanges succeeds, then the audit message is updated to indicate success * If SaveChanges fails, then the audit message is updated to indicate the failure -The first stage is handled before any changes are sent to the database using overrides of `ISaveChangesInterceptor.SavingChanges` and `ISaveChangesInterceptor.SavingChangesAsync`. +The first stage is handled before any changes are sent to the database using overrides of and . [!code-csharp[SavingChanges](../../../samples/core/Miscellaneous/SaveChangesInterception/AuditingInterceptor.cs?name=SavingChanges)] -Overriding both sync and async methods ensures that auditing will happen regardless of whether SaveChanges or SaveChangesAsync are called. Notice also that the async overload is itself able to perform non-blocking async I/O to the auditing database. You may wish to throw from the sync SavingChanges method to ensure that all database I/O is async. This then requires that the application always calls SaveChangesAsync and never SaveChanges. +Overriding both sync and async methods ensures that auditing will happen regardless of whether `SaveChanges` or `SaveChangesAsync` are called. Notice also that the async overload is itself able to perform non-blocking async I/O to the auditing database. You may wish to throw from the sync `SavingChanges` method to ensure that all database I/O is async. This then requires that the application always calls `SaveChangesAsync` and never `SaveChanges`. #### The audit message @@ -593,7 +593,7 @@ The result is a `SaveChangesAudit` entity with a collection of `EntityAudit` ent #### Detecting success -The audit entity is stored on the interceptor so that it can be accessed again once SaveChanges either succeeds or fails. For success, `ISaveChangesInterceptor.SavedChanges` or `ISaveChangesInterceptor.SavedChangesAsync` is called. +The audit entity is stored on the interceptor so that it can be accessed again once SaveChanges either succeeds or fails. For success, or is called. or `ISaveChangesInterceptor.SaveChangesFailedAsync` method. The event data contains the exception that was thrown. +Failure is handled in much the same way as success, but in the or method. The event data contains the exception that was thrown. when [configuring a DbContext instance](xref:core/dbcontext-configuration/index). This configuration is commonly done in an override of . For example: +EF Core logs can be accessed from any type of application through the use of when [configuring a DbContext instance](xref:core/dbcontext-configuration/index). This configuration is commonly done in an override of . For example: , as shown in the following sections. +This content can be customized by passing values from , as shown in the following sections. > [!TIP] > Consider using [Microsoft.Extensions.Logging](/aspnet/core/fundamentals/logging) for more control over log formatting. ### Using UTC time -By default, timestamnps are designed for local consumption while debugging. Use `DbContextLoggerOptions.DefaultWithUtcTime` to use culture-agnostic UTC timestamps instead, but keep everything else the same. For example: +By default, timestamps are designed for local consumption while debugging. Use to use culture-agnostic UTC timestamps instead, but keep everything else the same. For example: can be used to trim down the amount of metadata included in the log. This is can be useful in conjunction with single-line logging. For example: +Other flags in can be used to trim down the amount of metadata included in the log. This is can be useful in conjunction with single-line logging. For example: