Table of Contents

Class MigrationCommand

Namespace
Microsoft.EntityFrameworkCore.Migrations
Assembly
Microsoft.EntityFrameworkCore.Relational.dll

Represents a command ready to be sent to the database to migrate it.

public class MigrationCommand
Inheritance
MigrationCommand
Inherited Members

Constructors

MigrationCommand(IRelationalCommand, DbContext, IDiagnosticsLogger<Command>, bool)

Creates a new instance of the command.

public MigrationCommand(IRelationalCommand relationalCommand, DbContext context, IDiagnosticsLogger<DbLoggerCategory.Database.Command> logger, bool transactionSuppressed = false)

Parameters

relationalCommand IRelationalCommand

The underlying IRelationalCommand that will be used to execute the command.

context DbContext

The current Microsoft.EntityFrameworkCore.DbContext or null if not known.

logger IDiagnosticsLogger<Command>

The command logger.

transactionSuppressed bool

Indicates whether or not transactions should be suppressed while executing the command.

Properties

CommandLogger

The associated command logger.

public virtual IDiagnosticsLogger<DbLoggerCategory.Database.Command> CommandLogger { get; }

Property Value

IDiagnosticsLogger<Command>

CommandText

The SQL command text that will be executed against the database.

public virtual string CommandText { get; }

Property Value

string

TransactionSuppressed

Indicates whether or not transactions should be suppressed while executing the command.

public virtual bool TransactionSuppressed { get; }

Property Value

bool

Methods

ExecuteNonQuery(IRelationalConnection, IReadOnlyDictionary<string, object>)

Executes the command and returns the number of rows affected.

public virtual int ExecuteNonQuery(IRelationalConnection connection, IReadOnlyDictionary<string, object> parameterValues = null)

Parameters

connection IRelationalConnection

The connection to execute against.

parameterValues IReadOnlyDictionary<string, object>

The values for the parameters, or null if the command has no parameters.

Returns

int

The number of rows affected.

ExecuteNonQueryAsync(IRelationalConnection, IReadOnlyDictionary<string, object>, CancellationToken)

Executes the command and returns the number of rows affected.

public virtual Task<int> ExecuteNonQueryAsync(IRelationalConnection connection, IReadOnlyDictionary<string, object> parameterValues = null, CancellationToken cancellationToken = default)

Parameters

connection IRelationalConnection

The connection to execute against.

parameterValues IReadOnlyDictionary<string, object>

The values for the parameters, or null if the command has no parameters.

cancellationToken CancellationToken

A CancellationToken to observe while waiting for the task to complete.

Returns

Task<int>

A task that represents the asynchronous operation. The task result contains the number of rows affected.