Table of Contents

Class WarningsConfiguration

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

Represents configuration for which warnings should be thrown, logged, or ignored. by database providers or extensions. These options are set using WarningsConfigurationBuilder.

public class WarningsConfiguration
Inheritance
WarningsConfiguration
Inherited Members

Remarks

Instances of this class are designed to be immutable. To change an option, call one of the 'With...' methods to obtain a new instance with the option changed.

See Configuration for specific messages for more information and examples.

Constructors

WarningsConfiguration()

Creates a new, empty configuration, with all options set to their defaults.

public WarningsConfiguration()

WarningsConfiguration(WarningsConfiguration)

Called by a derived class constructor when implementing the Clone() method.

protected WarningsConfiguration(WarningsConfiguration copyFrom)

Parameters

copyFrom WarningsConfiguration

The instance that is being cloned.

Properties

DefaultBehavior

The option set from the DefaultBehavior method.

public virtual WarningBehavior DefaultBehavior { get; }

Property Value

WarningBehavior

Methods

Clone()

Override this method in a derived class to ensure that any clone created is also of that class.

protected virtual WarningsConfiguration Clone()

Returns

WarningsConfiguration

A clone of this instance, which can be modified before being returned as immutable.

GetBehavior(EventId)

Gets the WarningBehavior set for the given event ID, or null if no explicit behavior has been set.

public virtual WarningBehavior? GetBehavior(EventId eventId)

Parameters

eventId EventId

Returns

WarningBehavior?

GetLevel(EventId)

Gets the LogLevel set for the given event ID, or null if no explicit behavior has been set.

public virtual LogLevel? GetLevel(EventId eventId)

Parameters

eventId EventId

Returns

LogLevel?

The LogLevel set for the given event ID.

GetServiceProviderHashCode()

Returns a hash code created from any options that would cause a new IServiceProvider to be needed.

public virtual int GetServiceProviderHashCode()

Returns

int

A hash over options that require a new service provider when changed.

ShouldUseSameServiceProvider(WarningsConfiguration)

Returns a value indicating whether all of the options used in GetServiceProviderHashCode() are the same as in the given extension.

public virtual bool ShouldUseSameServiceProvider(WarningsConfiguration other)

Parameters

other WarningsConfiguration

The other configuration object.

Returns

bool

A value indicating whether all of the options that require a new service provider are the same.

TryWithExplicit(EventId, WarningBehavior)

Creates a new instance with the given explicit WarningBehavior set for the given event ID, but only if no explicit behavior has already been set. It is unusual to call this method directly. Instead use WarningsConfigurationBuilder.

public virtual WarningsConfiguration TryWithExplicit(EventId eventId, WarningBehavior warningBehavior)

Parameters

eventId EventId

The event ID for which the behavior should be set.

warningBehavior WarningBehavior

The behavior to set.

Returns

WarningsConfiguration

A new instance with the behavior set, or this instance if a behavior was already set.

WithDefaultBehavior(WarningBehavior)

Creates a new instance with all options the same as for this instance, but with the given option changed. It is unusual to call this method directly. Instead use WarningsConfigurationBuilder.

public virtual WarningsConfiguration WithDefaultBehavior(WarningBehavior warningBehavior)

Parameters

warningBehavior WarningBehavior

The option to change.

Returns

WarningsConfiguration

A new instance with the option changed.

Remarks

See Configuration for specific messages for more information and examples.

WithExplicit(IEnumerable<EventId>, WarningBehavior)

Creates a new instance with the given explicit WarningBehavior set for all given event IDs. It is unusual to call this method directly. Instead use WarningsConfigurationBuilder.

public virtual WarningsConfiguration WithExplicit(IEnumerable<EventId> eventIds, WarningBehavior warningBehavior)

Parameters

eventIds IEnumerable<EventId>

The event IDs for which the behavior should be set.

warningBehavior WarningBehavior

The behavior to set.

Returns

WarningsConfiguration

A new instance with the behaviors set.

WithExplicit(IEnumerable<(EventId Id, LogLevel Level)>)

Creates a new instance with the given log level set for all given event IDs. It is unusual to call this method directly. Instead use WarningsConfigurationBuilder.

public virtual WarningsConfiguration WithExplicit(IEnumerable<(EventId Id, LogLevel Level)> eventsAndLevels)

Parameters

eventsAndLevels IEnumerable<(EventId Id, LogLevel Level)>

The event IDs and corresponding log levels to set.

Returns

WarningsConfiguration

A new instance with the behaviors set.