IDbContextOptionsExtension Interface


Interface for extensions that are stored in Extensions.

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

public interface IDbContextOptionsExtension
type IDbContextOptionsExtension = interface
Public Interface IDbContextOptionsExtension



Information/metadata about the extension.


Creates a message fragment for logging typically containing information about any useful non-default options that have been configured.



Adds the services required to make the selected options work. This is used when there is no external IServiceProvider and EF is maintaining its own service provider internally. This allows database providers (and other extensions) to register their required services when EF is creating an service provider.


Returns a hash code created from any options that would cause a new IServiceProvider to be needed. Most extensions do not have any such options and should return zero.


Gives the extension a chance to validate that all options in the extension are valid. Most extensions do not have invalid combinations and so this will be a no-op. If options are invalid, then an exception should be thrown.

Applies to