INSERT all entities in the database.
All entities are considered as new rows and are
INSERTED in the database.
Inserting thousand of entities for an initial load or a file importation is a typical scenario.
SubmitChanges requires one database round-trip for every entity to
insert. So if you need to
insert 10000 entities, then 10000 database round-trips will be performed which is INSANELY slow.!
BulkInsert in counterpart requires the minimum database round-trips as possible. By example under the hood for SQL Server, a simple
SqlBulkCopy could be performed.
|Operations||1,000 Entities||2,000 Entities||5,000 Entities|
|SubmitChanges||1,000 ms||2,000 ms||5,000 ms|
|BulkInsert||6 ms||10 ms||15 ms|
You can specify more than one option using anonymous block.
You can specify a custom batch size using the
Read more: BatchSize
You can specify custom columns using the
Read more: ColumnInputExpression
To provide the best performance possible!
Since using the
ChangeTracker can greatly reduce performance, we chose to let
SubmitChanges method handle the scenarios with
BulkInsert the scenarios without it.
The major difference between both methods is
SubmitChanges uses the
ChangeTracker but not the
By skipping the
ChangeTracker, some methods like
DetectChanges are no longer required which greatly helps to improve the performance.