BulkExtensions in EF Core

In EF Core, if you want to improve your CRUD performance, you need to call BulkExtensions from the library made by ZZZ Projects.

They provide all common bulk extensions required when working with EF Core:

And even more features through their free library Entity Framework Plus.

How to create a Bulk Operations?

Without options, it's pretty simple. Instead of tracking your entities, you simply pass it to one of their methods, such as Bulk Insert:

context.BulkInsert(customers);

If you need an option like including all your entities graph, you need to create a lambda expression such as:

context.BulkInsert(customers, options => { options.IncludeGraph = true});

Why using Bulk Operations in EF Core?

The main reason people need to use Bulk Operations in EF Core is to improve their performance when importing thousand of entities. In addition to saving data, you also reduce your memory usage.

When processing a lot of entities, using Bulk Extensions instead of SaveChanges can be 5 times faster and use 20% of the memory.

References

Last updated