Bulk Insert: How to work with bulk insert operation?
One of the features that is particularly useful when inserting large amount of data is
bulk inserting. This is an optimized time-saving approach with few drawbacks that will be described later.
string database = null,
BulkInsertOptions options = null);
||Name of database for which bulk operation should be performed. If
DefaultDatabase from DocumentStore will be used.
||Bulk operations options that should be used.
There are several limitations to the API:
- Entity Id must be provided by the client. The client by default will use the HiLo generator in order to generate the Id.
- Transactions are per batch, not per operation, and DTC transactions are not supported.
- Documents inserted using bulk-insert will not raise notifications. More about
Changes API can be found here.
- Document Updates and Reference Checking must be explicitly turned on (see
AfterCommit method in
Put Triggers will be not executed in contrast to
- The default configuration of the bulk insert is not thread safe, ChunkedBulkInsertOptions inside BulkInsertOptions should be set to null in order to support multi threaded usage. Refer to BulkInsertOptions for more details
using (BulkInsertOperation bulkInsert = store.BulkInsert())
for (int i = 0; i < 1000 * 1000; i++)
FirstName = "FirstName #" + i,
LastName = "LastName #" + i