Share via


IDbConnectionInterceptor.ConnectionCreating Method

Definition

Called just before EF creates a DbConnection. This event is not triggered if the application provides the connection to use.

public virtual Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<System.Data.Common.DbConnection> ConnectionCreating (Microsoft.EntityFrameworkCore.Diagnostics.ConnectionCreatingEventData eventData, Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<System.Data.Common.DbConnection> result);
abstract member ConnectionCreating : Microsoft.EntityFrameworkCore.Diagnostics.ConnectionCreatingEventData * Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<System.Data.Common.DbConnection> -> Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<System.Data.Common.DbConnection>
override this.ConnectionCreating : Microsoft.EntityFrameworkCore.Diagnostics.ConnectionCreatingEventData * Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<System.Data.Common.DbConnection> -> Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<System.Data.Common.DbConnection>
Public Overridable Function ConnectionCreating (eventData As ConnectionCreatingEventData, result As InterceptionResult(Of DbConnection)) As InterceptionResult(Of DbConnection)

Parameters

eventData
ConnectionCreatingEventData

Contextual information about the connection.

result
InterceptionResult<DbConnection>

Represents the current result if one exists. This value will have HasResult set to true if some previous interceptor suppressed execution by calling SuppressWithResult(TResult). This value is typically used as the return value for the implementation of this method.

Returns

If HasResult is false, then EF will continue as normal. If HasResult is true, then EF will suppress the operation it was about to perform and use Result instead. An implementation of this method for any interceptor that is not attempting to change the result should return the result value passed in.

Applies to