DbContextOptionsBuilder<TContext>.EnableDetailedErrors(Boolean) Method

Definition

Enables detailed errors when handling data value exceptions that occur during processing of store query results. Such errors most often occur due to misconfiguration of entity properties. E.g. If a property is configured to be of type 'int', but the underlying data in the store is actually of type 'string', then an exception will be generated at runtime during processing of the data value. When this option is enabled and a data error is encountered, the generated exception will include details of the specific entity property that generated the error.

public virtual Microsoft.EntityFrameworkCore.DbContextOptionsBuilder<TContext> EnableDetailedErrors (bool detailedErrorsEnabled = true);
override this.EnableDetailedErrors : bool -> Microsoft.EntityFrameworkCore.DbContextOptionsBuilder<'Context (requires 'Context :> Microsoft.EntityFrameworkCore.DbContext)>
Public Overridable Function EnableDetailedErrors (Optional detailedErrorsEnabled As Boolean = true) As DbContextOptionsBuilder(Of TContext)

Parameters

detailedErrorsEnabled
Boolean

Returns

The same builder instance so that multiple calls can be chained.

Remarks

Enabling this option incurs a small performance overhead during query execution.

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