Entity Framework Extensions Batch Timeout

Description

Batch timeout is the number of seconds for the operation to complete before it times out.

The BatchTimeout gets or sets the maximum time in seconds to wait for a batch before the command throws a timeout exception. The following example modifies the timeout to 180 seconds when bulk saving data.

context.BulkSaveChanges(options => options.BatchTimeout = 180);

Try it: EF Core | EF6

You can also set batch size globally using EntityFrameworkManager.BulkOperationBuilder.

// Global
EntityFrameworkManager.BulkOperationBuilder = builder => builder.BatchTimeout = 180;

Purpose

Having access to change the BatchTimeout gives you the flexibility required when some operations are too slow to complete due to several reasons such as:

  • Batch Size
  • Column Size
  • Latency
  • Trigger
  • Etc.

Last updated: 2023-03-01
Author:


Contents