DbContextOptionsBuilder.ConfigureWarnings Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
ConfigureWarnings(Action<WarningsConfigurationBuilder>) |
Configures the runtime behavior of warnings generated by Entity Framework. You can set a default behavior and behaviors for each warning type. |
ConfigureWarnings(Action<WarningsConfigurationBuilder>) |
Configures the runtime behavior of warnings generated by Entity Framework. You can set a default behavior and behaviors for each warning type. |
ConfigureWarnings(Action<WarningsConfigurationBuilder>)
Configures the runtime behavior of warnings generated by Entity Framework. You can set a default behavior and behaviors for each warning type.
public virtual Microsoft.EntityFrameworkCore.DbContextOptionsBuilder ConfigureWarnings (Action<Microsoft.EntityFrameworkCore.Diagnostics.WarningsConfigurationBuilder> warningsConfigurationBuilderAction);
abstract member ConfigureWarnings : Action<Microsoft.EntityFrameworkCore.Diagnostics.WarningsConfigurationBuilder> -> Microsoft.EntityFrameworkCore.DbContextOptionsBuilder
override this.ConfigureWarnings : Action<Microsoft.EntityFrameworkCore.Diagnostics.WarningsConfigurationBuilder> -> Microsoft.EntityFrameworkCore.DbContextOptionsBuilder
Public Overridable Function ConfigureWarnings (warningsConfigurationBuilderAction As Action(Of WarningsConfigurationBuilder)) As DbContextOptionsBuilder
Parameters
- warningsConfigurationBuilderAction
- Action<WarningsConfigurationBuilder>
An action to configure the warning behavior.
Returns
The same builder instance so that multiple calls can be chained.
Examples
optionsBuilder.ConfigureWarnings(warnings =>
warnings.Default(WarningBehavior.Ignore)
.Log(CoreEventId.IncludeIgnoredWarning, CoreEventId.ModelValidationWarning)
.Throw(RelationalEventId.BoolWithDefaultWarning));
Remarks
Note that changing this configuration can cause EF to build a new internal service provider, which may cause issues with performance. Generally it is expected that no more than one or two different configurations will be used for a given application.
Note that if the application is setting the internal service provider through a call to UseInternalServiceProvider(IServiceProvider), then this option must configured the same way for all uses of that service provider. Consider instead not calling UseInternalServiceProvider(IServiceProvider) so that EF will manage the service providers and can create new instances as required.
See Using DbContextOptions and Logging for more information and examples.
Applies to
ConfigureWarnings(Action<WarningsConfigurationBuilder>)
Configures the runtime behavior of warnings generated by Entity Framework. You can set a default behavior and behaviors for each warning type.
public virtual Microsoft.EntityFrameworkCore.DbContextOptionsBuilder ConfigureWarnings (Action<Microsoft.EntityFrameworkCore.Infrastructure.WarningsConfigurationBuilder> warningsConfigurationBuilderAction);
abstract member ConfigureWarnings : Action<Microsoft.EntityFrameworkCore.Infrastructure.WarningsConfigurationBuilder> -> Microsoft.EntityFrameworkCore.DbContextOptionsBuilder
override this.ConfigureWarnings : Action<Microsoft.EntityFrameworkCore.Infrastructure.WarningsConfigurationBuilder> -> Microsoft.EntityFrameworkCore.DbContextOptionsBuilder
Public Overridable Function ConfigureWarnings (warningsConfigurationBuilderAction As Action(Of WarningsConfigurationBuilder)) As DbContextOptionsBuilder
Parameters
- warningsConfigurationBuilderAction
- Action<WarningsConfigurationBuilder>
An action to configure the warning behavior.
Returns
The same builder instance so that multiple calls can be chained.
Examples
optionsBuilder.ConfigureWarnings(warnings =>
warnings.Default(WarningBehavior.Ignore)
.Log(CoreEventId.IncludeIgnoredWarning, CoreEventId.ModelValidationWarning)
.Throw(RelationalEventId.QueryClientEvaluationWarning))
Applies to
Entity Framework