Microsoft.Data.SqlClient.SqlBulkCopyOptions
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.