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
IRelationalCommandThe underlying IRelationalCommand that will be used to execute the command.
context
DbContextThe current Microsoft.EntityFrameworkCore.DbContext or null if not known.
logger
IDiagnosticsLogger<Command>The command logger.
transactionSuppressed
boolIndicates 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
TransactionSuppressed
Indicates whether or not transactions should be suppressed while executing the command.
public virtual bool TransactionSuppressed { get; }
Property Value
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
IRelationalConnectionThe 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
IRelationalConnectionThe connection to execute against.
parameterValues
IReadOnlyDictionary<string, object>The values for the parameters, or null if the command has no parameters.
cancellationToken
CancellationTokenA CancellationToken to observe while waiting for the task to complete.