<PackageReference Include="Microsoft.Data.SqlClient" Version="7.1.0-preview1.26124.5" />

Microsoft.Data.SqlClient.SqlBulkCopyOptions

public enum SqlBulkCopyOptions
Bitwise flag that specifies one or more options to use with an instance of SqlBulkCopy.

When specified, AllowEncryptedValueModifications enables bulk copying of encrypted data between tables or databases, without decrypting the data. Typically, an application would select data from encrypted columns from one table without decrypting the data (the app would connect to the database with the column encryption setting keyword set to disabled) and then would use this option to bulk insert the data, which is still encrypted.

Use caution when specifying AllowEncryptedValueModifications as this may lead to corrupting the database because the driver does not check if the data is indeed encrypted, or if it is correctly encrypted using the same encryption type, algorithm and key as the target column.

When specified, CacheMetadata caches destination table metadata after the first bulk copy operation, allowing subsequent operations to the same table to skip the metadata discovery query. This can improve performance when performing multiple bulk copy operations to the same destination table.

Warning: Use this option only when you are certain the destination table schema will not change between bulk copy operations. If the table schema changes (columns added, removed, or modified), using cached metadata may result in data corruption, failed operations, or unexpected behavior. Call ClearCachedMetadata to clear the cache if the schema changes.

The cache is automatically invalidated when DestinationTableName is changed to a different table. Changing ColumnMappings between operations does not require cache invalidation because the cached metadata describes only the destination table schema, not the source-to-destination column mapping.

The cache is not automatically invalidated when the connection context changes. If the underlying SqlConnection changes database (for example, via ChangeDatabase) or reconnects to a different server due to failover, callers should call ClearCachedMetadata to ensure the metadata is refreshed.

Check constraints while data is being inserted. By default, constraints are not checked.

Default = 0

Use the default values for all options.

When specified, cause the server to fire the insert triggers for the rows being inserted into the database.

Preserve source identity values. When not specified, identity values are assigned by the destination.

Preserve null values in the destination table regardless of the settings for default values. When not specified, null values are replaced by default values where applicable.

Obtain a bulk update lock for the duration of the bulk copy operation. When not specified, row locks are used.

When specified, each batch of the bulk-copy operation will occur within a transaction. If you indicate this option and also provide a SqlTransaction object to the constructor, an ArgumentException occurs.