Table of Contents

Class CoreLoggerExtensions

Namespace
Microsoft.EntityFrameworkCore.Diagnostics
Assembly
Microsoft.EntityFrameworkCore.dll

This class contains static methods used by EF Core internals and database providers to write information to an ILogger and a DiagnosticListener for well-known events.

This type is typically used by database providers (and other extensions). It is generally not used in application code.

public static class CoreLoggerExtensions
Inheritance
CoreLoggerExtensions
Inherited Members

Remarks

See Implementation of database providers and extensions for more information and examples.

Methods

AmbiguousEndRequiredWarning(IDiagnosticsLogger<Model>, IForeignKey)

Logs for the AmbiguousEndRequiredWarning event.

public static void AmbiguousEndRequiredWarning(this IDiagnosticsLogger<DbLoggerCategory.Model> diagnostics, IForeignKey foreignKey)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.Model>

The diagnostics logger to use.

foreignKey IForeignKey

The foreign key.

CascadeDelete(IDiagnosticsLogger<Update>, InternalEntityEntry, InternalEntityEntry, EntityState)

Logs for the CascadeDelete event.

public static void CascadeDelete(this IDiagnosticsLogger<DbLoggerCategory.Update> diagnostics, InternalEntityEntry internalChildEntry, InternalEntityEntry internalParentEntry, EntityState state)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.Update>

The diagnostics logger to use.

internalChildEntry InternalEntityEntry

The child internal entity entry.

internalParentEntry InternalEntityEntry

The parent internal entity entry.

state EntityState

The target state.

CascadeDeleteOrphan(IDiagnosticsLogger<Update>, InternalEntityEntry, IEntityType, EntityState)

Logs for the CascadeDeleteOrphan event.

public static void CascadeDeleteOrphan(this IDiagnosticsLogger<DbLoggerCategory.Update> diagnostics, InternalEntityEntry internalChildEntry, IEntityType parentEntityType, EntityState state)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.Update>

The diagnostics logger to use.

internalChildEntry InternalEntityEntry

The child internal entity entry.

parentEntityType IEntityType

The parent entity type.

state EntityState

The target state.

CascadeDeleteOrphanSensitive(IDiagnosticsLogger<Update>, InternalEntityEntry, IEntityType, EntityState)

Logs for the CascadeDeleteOrphan event.

public static void CascadeDeleteOrphanSensitive(this IDiagnosticsLogger<DbLoggerCategory.Update> diagnostics, InternalEntityEntry internalChildEntry, IEntityType parentEntityType, EntityState state)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.Update>

The diagnostics logger to use.

internalChildEntry InternalEntityEntry

The child internal entity entry.

parentEntityType IEntityType

The parent entity type.

state EntityState

The target state.

CascadeDeleteSensitive(IDiagnosticsLogger<Update>, InternalEntityEntry, InternalEntityEntry, EntityState)

Logs for the CascadeDelete event.

public static void CascadeDeleteSensitive(this IDiagnosticsLogger<DbLoggerCategory.Update> diagnostics, InternalEntityEntry internalChildEntry, InternalEntityEntry internalParentEntry, EntityState state)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.Update>

The diagnostics logger to use.

internalChildEntry InternalEntityEntry

The child internal entity entry.

internalParentEntry InternalEntityEntry

The parent internal entity entry.

state EntityState

The target state.

CollectionChangeDetected(IDiagnosticsLogger<ChangeTracking>, InternalEntityEntry, INavigation, ISet<object>, ISet<object>)

Logs for the CollectionChangeDetected event.

public static void CollectionChangeDetected(this IDiagnosticsLogger<DbLoggerCategory.ChangeTracking> diagnostics, InternalEntityEntry internalEntityEntry, INavigation navigation, ISet<object> added, ISet<object> removed)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.ChangeTracking>

The diagnostics logger to use.

internalEntityEntry InternalEntityEntry

The internal entity entry.

navigation INavigation

The navigation property.

added ISet<object>

The added values.

removed ISet<object>

The removed values.

CollectionChangeDetectedSensitive(IDiagnosticsLogger<ChangeTracking>, InternalEntityEntry, INavigation, ISet<object>, ISet<object>)

Logs for the CollectionChangeDetected event.

public static void CollectionChangeDetectedSensitive(this IDiagnosticsLogger<DbLoggerCategory.ChangeTracking> diagnostics, InternalEntityEntry internalEntityEntry, INavigation navigation, ISet<object> added, ISet<object> removed)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.ChangeTracking>

The diagnostics logger to use.

internalEntityEntry InternalEntityEntry

The internal entity entry.

navigation INavigation

The navigation property.

added ISet<object>

The added values.

removed ISet<object>

The removed values.

CollectionWithoutComparer(IDiagnosticsLogger<Validation>, IProperty)

Logs for the CollectionWithoutComparer event.

public static void CollectionWithoutComparer(this IDiagnosticsLogger<DbLoggerCategory.Model.Validation> diagnostics, IProperty property)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.Model.Validation>

The diagnostics logger to use.

property IProperty

The property.

ConflictingForeignKeyAttributesOnNavigationAndPropertyWarning(IDiagnosticsLogger<Model>, IReadOnlyNavigation, MemberInfo)

public static void ConflictingForeignKeyAttributesOnNavigationAndPropertyWarning(this IDiagnosticsLogger<DbLoggerCategory.Model> diagnostics, IReadOnlyNavigation navigation, MemberInfo property)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.Model>

The diagnostics logger to use.

navigation IReadOnlyNavigation

The navigation property.

property MemberInfo

The property.

ConflictingKeylessAndKeyAttributesWarning(IDiagnosticsLogger<Model>, IReadOnlyProperty)

public static void ConflictingKeylessAndKeyAttributesWarning(this IDiagnosticsLogger<DbLoggerCategory.Model> diagnostics, IReadOnlyProperty property)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.Model>

The diagnostics logger to use.

property IReadOnlyProperty

The property which is being defined as part of a key.

ConflictingShadowForeignKeysWarning(IDiagnosticsLogger<Model>, IReadOnlyForeignKey)

public static void ConflictingShadowForeignKeysWarning(this IDiagnosticsLogger<DbLoggerCategory.Model> diagnostics, IReadOnlyForeignKey foreignKey)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.Model>

The diagnostics logger to use.

foreignKey IReadOnlyForeignKey

The foreign key.

ContextDisposed(IDiagnosticsLogger<Infrastructure>, DbContext)

Logs for the ContextDisposed event.

public static void ContextDisposed(this IDiagnosticsLogger<DbLoggerCategory.Infrastructure> diagnostics, DbContext context)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.Infrastructure>

The diagnostics logger to use.

context DbContext

The context being used.

ContextInitialized(IDiagnosticsLogger<Infrastructure>, DbContext, DbContextOptions)

Logs for the ContextInitialized event.

public static void ContextInitialized(this IDiagnosticsLogger<DbLoggerCategory.Infrastructure> diagnostics, DbContext context, DbContextOptions contextOptions)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.Infrastructure>

The diagnostics logger to use.

context DbContext

The context being used.

contextOptions DbContextOptions

The context options being used.

DetachedLazyLoadingWarning(IDiagnosticsLogger<Infrastructure>, DbContext?, object, string)

Logs for the DetachedLazyLoadingWarning event.

public static void DetachedLazyLoadingWarning(this IDiagnosticsLogger<DbLoggerCategory.Infrastructure> diagnostics, DbContext? context, object entityType, string navigationName)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.Infrastructure>

The diagnostics logger to use.

context DbContext

The context being used.

entityType object

The entity type.

navigationName string

The name of the navigation property.

DetectChangesCompleted(IDiagnosticsLogger<ChangeTracking>, DbContext)

Logs for the DetectChangesCompleted event.

public static void DetectChangesCompleted(this IDiagnosticsLogger<DbLoggerCategory.ChangeTracking> diagnostics, DbContext context)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.ChangeTracking>

The diagnostics logger to use.

context DbContext

The context being used.

DetectChangesStarting(IDiagnosticsLogger<ChangeTracking>, DbContext)

Logs for the DetectChangesStarting event.

public static void DetectChangesStarting(this IDiagnosticsLogger<DbLoggerCategory.ChangeTracking> diagnostics, DbContext context)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.ChangeTracking>

The diagnostics logger to use.

context DbContext

The context being used.

DistinctAfterOrderByWithoutRowLimitingOperatorWarning(IDiagnosticsLogger<Query>)

public static void DistinctAfterOrderByWithoutRowLimitingOperatorWarning(this IDiagnosticsLogger<DbLoggerCategory.Query> diagnostics)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.Query>

The diagnostics logger to use.

DuplicateDependentEntityTypeInstanceWarning(IDiagnosticsLogger<Update>, IEntityType, IEntityType)

public static void DuplicateDependentEntityTypeInstanceWarning(this IDiagnosticsLogger<DbLoggerCategory.Update> diagnostics, IEntityType dependent1, IEntityType dependent2)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.Update>

The diagnostics logger to use.

dependent1 IEntityType

The first dependent type.

dependent2 IEntityType

The second dependent type.

ExecutionStrategyRetrying(IDiagnosticsLogger<Infrastructure>, IReadOnlyList<Exception>, TimeSpan, bool)

Logs for the ExecutionStrategyRetrying event.

public static void ExecutionStrategyRetrying(this IDiagnosticsLogger<DbLoggerCategory.Infrastructure> diagnostics, IReadOnlyList<Exception> exceptionsEncountered, TimeSpan delay, bool async)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.Infrastructure>

The diagnostics logger to use.

exceptionsEncountered IReadOnlyList<Exception>

The exceptions(s) that caused the failure.

delay TimeSpan

The delay that before the next retry.

async bool

Indicates whether execution is asynchronous or not.

FirstWithoutOrderByAndFilterWarning(IDiagnosticsLogger<Query>)

public static void FirstWithoutOrderByAndFilterWarning(this IDiagnosticsLogger<DbLoggerCategory.Query> diagnostics)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.Query>

The diagnostics logger to use.

ForeignKeyAttributesOnBothNavigationsWarning(IDiagnosticsLogger<Model>, IReadOnlyNavigation, IReadOnlyNavigation)

public static void ForeignKeyAttributesOnBothNavigationsWarning(this IDiagnosticsLogger<DbLoggerCategory.Model> diagnostics, IReadOnlyNavigation firstNavigation, IReadOnlyNavigation secondNavigation)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.Model>

The diagnostics logger to use.

firstNavigation IReadOnlyNavigation

The first navigation property.

secondNavigation IReadOnlyNavigation

The second navigation property.

ForeignKeyAttributesOnBothPropertiesWarning(IDiagnosticsLogger<Model>, IReadOnlyNavigation, IReadOnlyNavigation, MemberInfo, MemberInfo)

public static void ForeignKeyAttributesOnBothPropertiesWarning(this IDiagnosticsLogger<DbLoggerCategory.Model> diagnostics, IReadOnlyNavigation firstNavigation, IReadOnlyNavigation secondNavigation, MemberInfo firstProperty, MemberInfo secondProperty)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.Model>

The diagnostics logger to use.

firstNavigation IReadOnlyNavigation

The first navigation property.

secondNavigation IReadOnlyNavigation

The second navigation property.

firstProperty MemberInfo

The first property.

secondProperty MemberInfo

The second property.

ForeignKeyChangeDetected(IDiagnosticsLogger<ChangeTracking>, InternalEntityEntry, IProperty, object?, object?)

Logs for the ForeignKeyChangeDetected event.

public static void ForeignKeyChangeDetected(this IDiagnosticsLogger<DbLoggerCategory.ChangeTracking> diagnostics, InternalEntityEntry internalEntityEntry, IProperty property, object? oldValue, object? newValue)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.ChangeTracking>

The diagnostics logger to use.

internalEntityEntry InternalEntityEntry

The internal entity entry.

property IProperty

The property.

oldValue object

The old value.

newValue object

the new value.

ForeignKeyChangeDetectedSensitive(IDiagnosticsLogger<ChangeTracking>, InternalEntityEntry, IProperty, object?, object?)

Logs for the ForeignKeyChangeDetected event.

public static void ForeignKeyChangeDetectedSensitive(this IDiagnosticsLogger<DbLoggerCategory.ChangeTracking> diagnostics, InternalEntityEntry internalEntityEntry, IProperty property, object? oldValue, object? newValue)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.ChangeTracking>

The diagnostics logger to use.

internalEntityEntry InternalEntityEntry

The internal entity entry.

property IProperty

The property.

oldValue object

The old value.

newValue object

The new value.

IncompatibleMatchingForeignKeyProperties(IDiagnosticsLogger<Model>, string, string, IReadOnlyList<IReadOnlyPropertyBase>, IReadOnlyList<IReadOnlyPropertyBase>)

public static void IncompatibleMatchingForeignKeyProperties(this IDiagnosticsLogger<DbLoggerCategory.Model> diagnostics, string dependentToPrincipalNavigationSpecification, string principalToDependentNavigationSpecification, IReadOnlyList<IReadOnlyPropertyBase> foreignKeyProperties, IReadOnlyList<IReadOnlyPropertyBase> principalKeyProperties)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.Model>

The diagnostics logger to use.

dependentToPrincipalNavigationSpecification string

The name of the navigation property or entity type on the dependent end of the relationship.

principalToDependentNavigationSpecification string

The name of the navigation property or entity type on the principal end of the relationship.

foreignKeyProperties IReadOnlyList<IReadOnlyPropertyBase>

The properties that make up the foreign key.

principalKeyProperties IReadOnlyList<IReadOnlyPropertyBase>

The corresponding keys on the principal side.

InvalidIncludePathError(IDiagnosticsLogger<Query>, string, string)

Logs for the InvalidIncludePathError event.

public static void InvalidIncludePathError(this IDiagnosticsLogger<DbLoggerCategory.Query> diagnostics, string navigationChain, string navigationName)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.Query>

The diagnostics logger to use.

navigationChain string

The navigation chain used in the Include<TEntity>(IQueryable<TEntity>, string)

navigationName string

The navigation name which was not found in the model.

LazyLoadOnDisposedContextWarning(IDiagnosticsLogger<Infrastructure>, DbContext?, object, string)

public static void LazyLoadOnDisposedContextWarning(this IDiagnosticsLogger<DbLoggerCategory.Infrastructure> diagnostics, DbContext? context, object entityType, string navigationName)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.Infrastructure>

The diagnostics logger to use.

context DbContext

The context being used.

entityType object

The entity type.

navigationName string

The name of the navigation property.

ManyServiceProvidersCreatedWarning(IDiagnosticsLogger<Infrastructure>, ICollection<IServiceProvider>)

public static void ManyServiceProvidersCreatedWarning(this IDiagnosticsLogger<DbLoggerCategory.Infrastructure> diagnostics, ICollection<IServiceProvider> serviceProviders)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.Infrastructure>

The diagnostics logger to use.

serviceProviders ICollection<IServiceProvider>

The service providers that have been created.

MappedComplexPropertyIgnoredWarning(IDiagnosticsLogger<Model>, IComplexProperty)

public static void MappedComplexPropertyIgnoredWarning(this IDiagnosticsLogger<DbLoggerCategory.Model> diagnostics, IComplexProperty property)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.Model>

The diagnostics logger to use.

property IComplexProperty

The property.

MappedEntityTypeIgnoredWarning(IDiagnosticsLogger<Model>, IEntityType)

Logs for the MappedEntityTypeIgnoredWarning event.

public static void MappedEntityTypeIgnoredWarning(this IDiagnosticsLogger<DbLoggerCategory.Model> diagnostics, IEntityType entityType)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.Model>

The diagnostics logger to use.

entityType IEntityType

The entity type.

MappedNavigationIgnoredWarning(IDiagnosticsLogger<Model>, INavigationBase)

Logs for the MappedNavigationIgnoredWarning event.

public static void MappedNavigationIgnoredWarning(this IDiagnosticsLogger<DbLoggerCategory.Model> diagnostics, INavigationBase navigation)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.Model>

The diagnostics logger to use.

navigation INavigationBase

The navigation.

MappedPropertyIgnoredWarning(IDiagnosticsLogger<Model>, IProperty)

Logs for the MappedPropertyIgnoredWarning event.

public static void MappedPropertyIgnoredWarning(this IDiagnosticsLogger<DbLoggerCategory.Model> diagnostics, IProperty property)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.Model>

The diagnostics logger to use.

property IProperty

The property.

MultipleInversePropertiesSameTargetWarning(IDiagnosticsLogger<Model>, IEnumerable<Tuple<MemberInfo?, Type>>, MemberInfo, Type)

public static void MultipleInversePropertiesSameTargetWarning(this IDiagnosticsLogger<DbLoggerCategory.Model> diagnostics, IEnumerable<Tuple<MemberInfo?, Type>> conflictingNavigations, MemberInfo inverseNavigation, Type targetType)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.Model>

The diagnostics logger to use.

conflictingNavigations IEnumerable<Tuple<MemberInfo, Type>>

The list of conflicting navigation properties.

inverseNavigation MemberInfo

The inverse navigation property.

targetType Type

The target type.

MultipleNavigationProperties(IDiagnosticsLogger<Model>, IEnumerable<Tuple<MemberInfo?, Type>>, IEnumerable<Tuple<MemberInfo?, Type>>)

Logs for the MultipleNavigationProperties event.

public static void MultipleNavigationProperties(this IDiagnosticsLogger<DbLoggerCategory.Model> diagnostics, IEnumerable<Tuple<MemberInfo?, Type>> firstPropertyCollection, IEnumerable<Tuple<MemberInfo?, Type>> secondPropertyCollection)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.Model>

The diagnostics logger to use.

firstPropertyCollection IEnumerable<Tuple<MemberInfo, Type>>

The first set of properties.

secondPropertyCollection IEnumerable<Tuple<MemberInfo, Type>>

The second set of properties.

MultiplePrimaryKeyCandidates(IDiagnosticsLogger<Model>, IReadOnlyProperty, IReadOnlyProperty)

Logs for the MultiplePrimaryKeyCandidates event.

public static void MultiplePrimaryKeyCandidates(this IDiagnosticsLogger<DbLoggerCategory.Model> diagnostics, IReadOnlyProperty firstProperty, IReadOnlyProperty secondProperty)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.Model>

The diagnostics logger to use.

firstProperty IReadOnlyProperty

The first property.

secondProperty IReadOnlyProperty

The second property.

NavigationBaseIncludeIgnored(IDiagnosticsLogger<Query>, INavigationBase)

Logs for the NavigationBaseIncludeIgnored event.

public static void NavigationBaseIncludeIgnored(this IDiagnosticsLogger<DbLoggerCategory.Query> diagnostics, INavigationBase navigation)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.Query>

The diagnostics logger to use.

navigation INavigationBase

The navigation being included.

NavigationBaseIncluded(IDiagnosticsLogger<Query>, INavigationBase)

Logs for the NavigationBaseIncluded event.

public static void NavigationBaseIncluded(this IDiagnosticsLogger<DbLoggerCategory.Query> diagnostics, INavigationBase navigation)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.Query>

The diagnostics logger to use.

navigation INavigationBase

The navigation being included.

NavigationLazyLoading(IDiagnosticsLogger<Infrastructure>, DbContext, object, string)

Logs for the NavigationLazyLoading event.

public static void NavigationLazyLoading(this IDiagnosticsLogger<DbLoggerCategory.Infrastructure> diagnostics, DbContext context, object entityType, string navigationName)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.Infrastructure>

The diagnostics logger to use.

context DbContext

The context being used.

entityType object

The entity type.

navigationName string

The name of the navigation property.

NonOwnershipInverseNavigationWarning(IDiagnosticsLogger<Model>, IReadOnlyEntityType, MemberInfo, IReadOnlyEntityType, MemberInfo, MemberInfo)

public static void NonOwnershipInverseNavigationWarning(this IDiagnosticsLogger<DbLoggerCategory.Model> diagnostics, IReadOnlyEntityType declaringType, MemberInfo navigation, IReadOnlyEntityType targetType, MemberInfo inverseNavigation, MemberInfo ownershipNavigation)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.Model>

The diagnostics logger to use.

declaringType IReadOnlyEntityType

The declaring entity type.

navigation MemberInfo

The navigation property.

targetType IReadOnlyEntityType

The target type.

inverseNavigation MemberInfo

The inverse navigation property.

ownershipNavigation MemberInfo

The ownership navigation property.

OldModelVersionWarning(IDiagnosticsLogger<Infrastructure>, DbContext, DbContextOptions)

Logs for the OldModelVersionWarning event.

public static void OldModelVersionWarning(this IDiagnosticsLogger<DbLoggerCategory.Infrastructure> diagnostics, DbContext context, DbContextOptions contextOptions)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.Infrastructure>

The diagnostics logger to use.

context DbContext

The context being used.

contextOptions DbContextOptions

The context options being used.

OptimisticConcurrencyException(IDiagnosticsLogger<Update>, DbContext, IReadOnlyList<IUpdateEntry>, DbUpdateConcurrencyException, Func<DbContext, DbUpdateConcurrencyException, IReadOnlyList<IUpdateEntry>, EventDefinition<Exception>, ConcurrencyExceptionEventData>?)

Logs for the OptimisticConcurrencyException event.

public static InterceptionResult OptimisticConcurrencyException(this IDiagnosticsLogger<DbLoggerCategory.Update> diagnostics, DbContext context, IReadOnlyList<IUpdateEntry> entries, DbUpdateConcurrencyException exception, Func<DbContext, DbUpdateConcurrencyException, IReadOnlyList<IUpdateEntry>, EventDefinition<Exception>, ConcurrencyExceptionEventData>? createEventData)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.Update>

The diagnostics logger to use.

context DbContext

The context in use.

entries IReadOnlyList<IUpdateEntry>

The entries that were involved in the concurrency violation.

exception DbUpdateConcurrencyException

The exception that caused this event.

createEventData Func<DbContext, DbUpdateConcurrencyException, IReadOnlyList<IUpdateEntry>, EventDefinition<Exception>, ConcurrencyExceptionEventData>

Optional delegate to override event data creation.

Returns

InterceptionResult

OptimisticConcurrencyExceptionAsync(IDiagnosticsLogger<Update>, DbContext, IReadOnlyList<IUpdateEntry>, DbUpdateConcurrencyException, Func<DbContext, DbUpdateConcurrencyException, IReadOnlyList<IUpdateEntry>, EventDefinition<Exception>, ConcurrencyExceptionEventData>?, CancellationToken)

Logs for the OptimisticConcurrencyException event.

public static ValueTask<InterceptionResult> OptimisticConcurrencyExceptionAsync(this IDiagnosticsLogger<DbLoggerCategory.Update> diagnostics, DbContext context, IReadOnlyList<IUpdateEntry> entries, DbUpdateConcurrencyException exception, Func<DbContext, DbUpdateConcurrencyException, IReadOnlyList<IUpdateEntry>, EventDefinition<Exception>, ConcurrencyExceptionEventData>? createEventData, CancellationToken cancellationToken = default)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.Update>

The diagnostics logger to use.

context DbContext

The context in use.

entries IReadOnlyList<IUpdateEntry>

The entries that were involved in the concurrency violation.

exception DbUpdateConcurrencyException

The exception that caused this event.

createEventData Func<DbContext, DbUpdateConcurrencyException, IReadOnlyList<IUpdateEntry>, EventDefinition<Exception>, ConcurrencyExceptionEventData>

Optional delegate to override event data creation.

cancellationToken CancellationToken

A CancellationToken to observe while waiting for the task to complete.

Returns

ValueTask<InterceptionResult>

A Task for the async result.

Exceptions

OperationCanceledException

If the CancellationToken is canceled.

PossibleIncorrectRequiredNavigationWithQueryFilterInteractionWarning(IDiagnosticsLogger<Validation>, IForeignKey)

public static void PossibleIncorrectRequiredNavigationWithQueryFilterInteractionWarning(this IDiagnosticsLogger<DbLoggerCategory.Model.Validation> diagnostics, IForeignKey foreignKey)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.Model.Validation>

The diagnostics logger to use.

foreignKey IForeignKey

Foreign key which is used in the incorrectly setup navigation.

PossibleUnintendedCollectionNavigationNullComparisonWarning(IDiagnosticsLogger<Query>, INavigation)

public static void PossibleUnintendedCollectionNavigationNullComparisonWarning(this IDiagnosticsLogger<DbLoggerCategory.Query> diagnostics, INavigation navigation)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.Query>

The diagnostics logger to use.

navigation INavigation

The navigation being used.

PossibleUnintendedReferenceComparisonWarning(IDiagnosticsLogger<Query>, Expression, Expression)

public static void PossibleUnintendedReferenceComparisonWarning(this IDiagnosticsLogger<DbLoggerCategory.Query> diagnostics, Expression left, Expression right)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.Query>

The diagnostics logger to use.

left Expression

The left side expression.

right Expression

The right side expression.

PropertyChangeDetected(IDiagnosticsLogger<ChangeTracking>, InternalEntityEntry, IProperty, object?, object?)

Logs for the PropertyChangeDetected event.

public static void PropertyChangeDetected(this IDiagnosticsLogger<DbLoggerCategory.ChangeTracking> diagnostics, InternalEntityEntry internalEntityEntry, IProperty property, object? oldValue, object? newValue)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.ChangeTracking>

The diagnostics logger to use.

internalEntityEntry InternalEntityEntry

The internal entity entry.

property IProperty

The property.

oldValue object

The old value.

newValue object

The new value.

PropertyChangeDetectedSensitive(IDiagnosticsLogger<ChangeTracking>, InternalEntityEntry, IProperty, object?, object?)

Logs for the PropertyChangeDetected event.

public static void PropertyChangeDetectedSensitive(this IDiagnosticsLogger<DbLoggerCategory.ChangeTracking> diagnostics, InternalEntityEntry internalEntityEntry, IProperty property, object? oldValue, object? newValue)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.ChangeTracking>

The diagnostics logger to use.

internalEntityEntry InternalEntityEntry

The internal entity entry.

property IProperty

The property.

oldValue object

The old value.

newValue object

The new value.

QueryCanceled(IDiagnosticsLogger<Query>, Type)

Logs for the QueryCanceled event.

public static void QueryCanceled(this IDiagnosticsLogger<DbLoggerCategory.Query> diagnostics, Type contextType)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.Query>

The diagnostics logger to use.

contextType Type

The DbContext type being used.

QueryCompilationStarting(IDiagnosticsLogger<Query>, DbContext?, ExpressionPrinter, Expression)

Logs for the QueryCompilationStarting event.

public static (Expression Query, QueryExpressionEventData? EventData) QueryCompilationStarting(this IDiagnosticsLogger<DbLoggerCategory.Query> diagnostics, DbContext? context, ExpressionPrinter expressionPrinter, Expression queryExpression)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.Query>

The diagnostics logger to use.

context DbContext

The current DbContext, or null if not known.

expressionPrinter ExpressionPrinter

Used to create a human-readable representation of the expression tree.

queryExpression Expression

The query expression tree.

Returns

(Expression Query, QueryExpressionEventData EventData)

The query expression and event data.

QueryExecutionPlanned(IDiagnosticsLogger<Query>, DbContext?, ExpressionPrinter, Expression)

Logs for the QueryExecutionPlanned event.

public static void QueryExecutionPlanned(this IDiagnosticsLogger<DbLoggerCategory.Query> diagnostics, DbContext? context, ExpressionPrinter expressionPrinter, Expression queryExecutorExpression)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.Query>

The diagnostics logger to use.

context DbContext

The current DbContext, or null if not known.

expressionPrinter ExpressionPrinter

Used to create a human-readable representation of the expression tree.

queryExecutorExpression Expression

The query expression tree.

QueryIterationFailed(IDiagnosticsLogger<Query>, Type, Exception)

Logs for the QueryIterationFailed event.

public static void QueryIterationFailed(this IDiagnosticsLogger<DbLoggerCategory.Query> diagnostics, Type contextType, Exception exception)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.Query>

The diagnostics logger to use.

contextType Type

The DbContext type being used.

exception Exception

The exception that caused this failure.

RedundantAddServicesCallWarning(IDiagnosticsLogger<Infrastructure>, IServiceProvider)

Logs for the RedundantAddServicesCallWarning event.

public static void RedundantAddServicesCallWarning(this IDiagnosticsLogger<DbLoggerCategory.Infrastructure> diagnostics, IServiceProvider serviceProvider)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.Infrastructure>

The diagnostics logger to use.

serviceProvider IServiceProvider

The service provider used.

RedundantForeignKeyWarning(IDiagnosticsLogger<Validation>, IForeignKey)

Logs for the RedundantForeignKeyWarning event.

public static void RedundantForeignKeyWarning(this IDiagnosticsLogger<DbLoggerCategory.Model.Validation> diagnostics, IForeignKey redundantForeignKey)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.Model.Validation>

The diagnostics logger to use.

redundantForeignKey IForeignKey

The redundant foreign key.

RedundantIndexRemoved(IDiagnosticsLogger<Model>, IReadOnlyList<IReadOnlyPropertyBase>, IReadOnlyList<IReadOnlyPropertyBase>)

Logs for the RedundantIndexRemoved event.

public static void RedundantIndexRemoved(this IDiagnosticsLogger<DbLoggerCategory.Model> diagnostics, IReadOnlyList<IReadOnlyPropertyBase> redundantIndex, IReadOnlyList<IReadOnlyPropertyBase> otherIndex)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.Model>

The diagnostics logger to use.

redundantIndex IReadOnlyList<IReadOnlyPropertyBase>

The redundant index.

otherIndex IReadOnlyList<IReadOnlyPropertyBase>

The other index.

ReferenceChangeDetected(IDiagnosticsLogger<ChangeTracking>, InternalEntityEntry, INavigation, object?, object?)

Logs for the ReferenceChangeDetected event.

public static void ReferenceChangeDetected(this IDiagnosticsLogger<DbLoggerCategory.ChangeTracking> diagnostics, InternalEntityEntry internalEntityEntry, INavigation navigation, object? oldValue, object? newValue)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.ChangeTracking>

The diagnostics logger to use.

internalEntityEntry InternalEntityEntry

The internal entity entry.

navigation INavigation

The navigation property.

oldValue object

The old value.

newValue object

The new value.

ReferenceChangeDetectedSensitive(IDiagnosticsLogger<ChangeTracking>, InternalEntityEntry, INavigation, object?, object?)

Logs for the ReferenceChangeDetected event.

public static void ReferenceChangeDetectedSensitive(this IDiagnosticsLogger<DbLoggerCategory.ChangeTracking> diagnostics, InternalEntityEntry internalEntityEntry, INavigation navigation, object? oldValue, object? newValue)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.ChangeTracking>

The diagnostics logger to use.

internalEntityEntry InternalEntityEntry

The internal entity entry.

navigation INavigation

The navigation property.

oldValue object

The old value.

newValue object

The new value.

RequiredAttributeOnCollection(IDiagnosticsLogger<Model>, IReadOnlyNavigation)

Logs for the RequiredAttributeOnCollection event.

public static void RequiredAttributeOnCollection(this IDiagnosticsLogger<DbLoggerCategory.Model> diagnostics, IReadOnlyNavigation navigation)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.Model>

The diagnostics logger to use.

navigation IReadOnlyNavigation

The navigation property.

RequiredAttributeOnSkipNavigation(IDiagnosticsLogger<Model>, IReadOnlySkipNavigation)

public static void RequiredAttributeOnSkipNavigation(this IDiagnosticsLogger<DbLoggerCategory.Model> diagnostics, IReadOnlySkipNavigation navigation)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.Model>

The diagnostics logger to use.

navigation IReadOnlySkipNavigation

The navigation property.

RowLimitingOperationWithoutOrderByWarning(IDiagnosticsLogger<Query>)

public static void RowLimitingOperationWithoutOrderByWarning(this IDiagnosticsLogger<DbLoggerCategory.Query> diagnostics)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.Query>

The diagnostics logger to use.

SaveChangesCanceled(IDiagnosticsLogger<Update>, DbContext)

Logs for the SaveChangesFailed event.

public static void SaveChangesCanceled(this IDiagnosticsLogger<DbLoggerCategory.Update> diagnostics, DbContext context)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.Update>

The diagnostics logger to use.

context DbContext

The context in use.

SaveChangesCanceledAsync(IDiagnosticsLogger<Update>, DbContext, CancellationToken)

Logs for the SaveChangesFailed event.

public static Task SaveChangesCanceledAsync(this IDiagnosticsLogger<DbLoggerCategory.Update> diagnostics, DbContext context, CancellationToken cancellationToken = default)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.Update>

The diagnostics logger to use.

context DbContext

The context in use.

cancellationToken CancellationToken

A CancellationToken to observe while waiting for the task to complete.

Returns

Task

A Task for the async result.

Exceptions

OperationCanceledException

If the CancellationToken is canceled.

SaveChangesCompleted(IDiagnosticsLogger<Update>, DbContext, int)

Logs for the SaveChangesCompleted event.

public static int SaveChangesCompleted(this IDiagnosticsLogger<DbLoggerCategory.Update> diagnostics, DbContext context, int entitiesSavedCount)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.Update>

The diagnostics logger to use.

context DbContext

The context being used.

entitiesSavedCount int

The number of entities saved.

Returns

int

The, possibly intercepted, result.

SaveChangesCompletedAsync(IDiagnosticsLogger<Update>, DbContext, int, CancellationToken)

Logs for the SaveChangesCompleted event.

public static ValueTask<int> SaveChangesCompletedAsync(this IDiagnosticsLogger<DbLoggerCategory.Update> diagnostics, DbContext context, int entitiesSavedCount, CancellationToken cancellationToken = default)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.Update>

The diagnostics logger to use.

context DbContext

The context being used.

entitiesSavedCount int

The number of entities saved.

cancellationToken CancellationToken

A CancellationToken to observe while waiting for the task to complete.

Returns

ValueTask<int>

The, possibly intercepted, result.

Exceptions

OperationCanceledException

If the CancellationToken is canceled.

SaveChangesFailed(IDiagnosticsLogger<Update>, DbContext, Exception)

Logs for the SaveChangesFailed event.

public static void SaveChangesFailed(this IDiagnosticsLogger<DbLoggerCategory.Update> diagnostics, DbContext context, Exception exception)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.Update>

The diagnostics logger to use.

context DbContext

The context in use.

exception Exception

The exception that caused this event.

SaveChangesFailedAsync(IDiagnosticsLogger<Update>, DbContext, Exception, CancellationToken)

Logs for the SaveChangesFailed event.

public static Task SaveChangesFailedAsync(this IDiagnosticsLogger<DbLoggerCategory.Update> diagnostics, DbContext context, Exception exception, CancellationToken cancellationToken = default)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.Update>

The diagnostics logger to use.

context DbContext

The context in use.

exception Exception

The exception that caused this event.

cancellationToken CancellationToken

A CancellationToken to observe while waiting for the task to complete.

Returns

Task

A Task for the async result.

Exceptions

OperationCanceledException

If the CancellationToken is canceled.

SaveChangesStarting(IDiagnosticsLogger<Update>, DbContext)

Logs for the SaveChangesStarting event.

public static InterceptionResult<int> SaveChangesStarting(this IDiagnosticsLogger<DbLoggerCategory.Update> diagnostics, DbContext context)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.Update>

The diagnostics logger to use.

context DbContext

The context being used.

Returns

InterceptionResult<int>

The, possibly intercepted, result.

SaveChangesStartingAsync(IDiagnosticsLogger<Update>, DbContext, CancellationToken)

Logs for the SaveChangesStarting event.

public static ValueTask<InterceptionResult<int>> SaveChangesStartingAsync(this IDiagnosticsLogger<DbLoggerCategory.Update> diagnostics, DbContext context, CancellationToken cancellationToken = default)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.Update>

The diagnostics logger to use.

context DbContext

The context being used.

cancellationToken CancellationToken

A CancellationToken to observe while waiting for the task to complete.

Returns

ValueTask<InterceptionResult<int>>

The, possibly intercepted, result.

Exceptions

OperationCanceledException

If the CancellationToken is canceled.

SensitiveDataLoggingEnabledWarning<TLoggerCategory>(IDiagnosticsLogger<TLoggerCategory>)

public static void SensitiveDataLoggingEnabledWarning<TLoggerCategory>(this IDiagnosticsLogger<TLoggerCategory> diagnostics) where TLoggerCategory : LoggerCategory<TLoggerCategory>, new()

Parameters

diagnostics IDiagnosticsLogger<TLoggerCategory>

The diagnostics logger to use.

Type Parameters

TLoggerCategory

The logger category for which to log the warning.

ServiceProviderCreated(IDiagnosticsLogger<Infrastructure>, IServiceProvider)

Logs for the ServiceProviderCreated event.

public static void ServiceProviderCreated(this IDiagnosticsLogger<DbLoggerCategory.Infrastructure> diagnostics, IServiceProvider serviceProvider)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.Infrastructure>

The diagnostics logger to use.

serviceProvider IServiceProvider

The service provider.

ServiceProviderDebugInfo(IDiagnosticsLogger<Infrastructure>, IDictionary<string, string>, IList<IDictionary<string, string>>)

Logs for the ServiceProviderDebugInfo event.

public static void ServiceProviderDebugInfo(this IDiagnosticsLogger<DbLoggerCategory.Infrastructure> diagnostics, IDictionary<string, string> newDebugInfo, IList<IDictionary<string, string>> cachedDebugInfos)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.Infrastructure>

The diagnostics logger to use.

newDebugInfo IDictionary<string, string>

Debug information for the new service providers.

cachedDebugInfos IList<IDictionary<string, string>>

Debug information for existing service providers.

ShadowForeignKeyPropertyCreated(IDiagnosticsLogger<Validation>, IProperty, string)

Logs for the ShadowForeignKeyPropertyCreated event.

public static void ShadowForeignKeyPropertyCreated(this IDiagnosticsLogger<DbLoggerCategory.Model.Validation> diagnostics, IProperty property, string basePropertyName)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.Model.Validation>

The diagnostics logger to use.

property IProperty

The property.

basePropertyName string

The property name that was uniquified.

ShadowPropertyCreated(IDiagnosticsLogger<Validation>, IProperty)

Logs for the ShadowPropertyCreated event.

public static void ShadowPropertyCreated(this IDiagnosticsLogger<DbLoggerCategory.Model.Validation> diagnostics, IProperty property)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.Model.Validation>

The diagnostics logger to use.

property IProperty

The property.

SkipCollectionChangeDetected(IDiagnosticsLogger<ChangeTracking>, InternalEntityEntry, ISkipNavigation, ISet<object>, ISet<object>)

Logs for the CollectionChangeDetected event.

public static void SkipCollectionChangeDetected(this IDiagnosticsLogger<DbLoggerCategory.ChangeTracking> diagnostics, InternalEntityEntry internalEntityEntry, ISkipNavigation navigation, ISet<object> added, ISet<object> removed)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.ChangeTracking>

The diagnostics logger to use.

internalEntityEntry InternalEntityEntry

The internal entity entry.

navigation ISkipNavigation

The navigation property.

added ISet<object>

The added values.

removed ISet<object>

The removed values.

SkipCollectionChangeDetectedSensitive(IDiagnosticsLogger<ChangeTracking>, InternalEntityEntry, ISkipNavigation, ISet<object>, ISet<object>)

Logs for the CollectionChangeDetected event.

public static void SkipCollectionChangeDetectedSensitive(this IDiagnosticsLogger<DbLoggerCategory.ChangeTracking> diagnostics, InternalEntityEntry internalEntityEntry, ISkipNavigation navigation, ISet<object> added, ISet<object> removed)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.ChangeTracking>

The diagnostics logger to use.

internalEntityEntry InternalEntityEntry

The internal entity entry.

navigation ISkipNavigation

The navigation property.

added ISet<object>

The added values.

removed ISet<object>

The removed values.

StartedTracking(IDiagnosticsLogger<ChangeTracking>, InternalEntityEntry)

Logs for the StartedTracking event.

public static void StartedTracking(this IDiagnosticsLogger<DbLoggerCategory.ChangeTracking> diagnostics, InternalEntityEntry internalEntityEntry)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.ChangeTracking>

The diagnostics logger to use.

internalEntityEntry InternalEntityEntry

The internal entity entry.

StartedTrackingSensitive(IDiagnosticsLogger<ChangeTracking>, InternalEntityEntry)

Logs for the StartedTracking event.

public static void StartedTrackingSensitive(this IDiagnosticsLogger<DbLoggerCategory.ChangeTracking> diagnostics, InternalEntityEntry internalEntityEntry)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.ChangeTracking>

The diagnostics logger to use.

internalEntityEntry InternalEntityEntry

The internal entity entry.

StateChanged(IDiagnosticsLogger<ChangeTracking>, InternalEntityEntry, EntityState, EntityState)

Logs for the StateChanged event.

public static void StateChanged(this IDiagnosticsLogger<DbLoggerCategory.ChangeTracking> diagnostics, InternalEntityEntry internalEntityEntry, EntityState oldState, EntityState newState)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.ChangeTracking>

The diagnostics logger to use.

internalEntityEntry InternalEntityEntry

The internal entity entry.

oldState EntityState

The old value.

newState EntityState

The new value.

StateChangedSensitive(IDiagnosticsLogger<ChangeTracking>, InternalEntityEntry, EntityState, EntityState)

Logs for the StateChanged event.

public static void StateChangedSensitive(this IDiagnosticsLogger<DbLoggerCategory.ChangeTracking> diagnostics, InternalEntityEntry internalEntityEntry, EntityState oldState, EntityState newState)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.ChangeTracking>

The diagnostics logger to use.

internalEntityEntry InternalEntityEntry

The internal entity entry.

oldState EntityState

The old state.

newState EntityState

The new state.

StringEnumValueInJson(IDiagnosticsLogger<Query>, Type)

Logs for the StringEnumValueInJson event.

public static void StringEnumValueInJson(this IDiagnosticsLogger<DbLoggerCategory.Query> diagnostics, Type enumType)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.Query>

The diagnostics logger to use.

enumType Type

The type.

ValueGenerated(IDiagnosticsLogger<ChangeTracking>, InternalEntityEntry, IProperty, object?, bool)

Logs for the ValueGenerated event.

public static void ValueGenerated(this IDiagnosticsLogger<DbLoggerCategory.ChangeTracking> diagnostics, InternalEntityEntry internalEntityEntry, IProperty property, object? value, bool temporary)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.ChangeTracking>

The diagnostics logger to use.

internalEntityEntry InternalEntityEntry

The internal entity entry.

property IProperty

The property.

value object

The value generated.

temporary bool

Indicates whether or not the value is a temporary or permanent value.

ValueGeneratedSensitive(IDiagnosticsLogger<ChangeTracking>, InternalEntityEntry, IProperty, object?, bool)

Logs for the ValueGenerated event.

public static void ValueGeneratedSensitive(this IDiagnosticsLogger<DbLoggerCategory.ChangeTracking> diagnostics, InternalEntityEntry internalEntityEntry, IProperty property, object? value, bool temporary)

Parameters

diagnostics IDiagnosticsLogger<DbLoggerCategory.ChangeTracking>

The diagnostics logger to use.

internalEntityEntry InternalEntityEntry

The internal entity entry.

property IProperty

The property.

value object

The value generated.

temporary bool

Indicates whether or not the value is a temporary or permanent value.