Entity Framework Extensions EF Extensions for EF Core 8 - What is New?
EF Core 8 was finally released on November 14, 2023, along with some new features, bug fixes, and breaking changes.
Every new major EF Core version brings some new challenges for our Entity Framework library to ensure our Bulk Extensions methods always become faster, use less memory, and be extensible than our previous version. One of our biggest challenges this time was the introduction of the Complex Type, which our library already fully supports.
You can download Entity Framework Extensions for all EF Core versions here: Z.EntityFramework.Extensions.EFCore NuGet
EF Core Pinned Version Increased
EF Extensions follow a EFCore-Pinned Versioning convention [efcore-version].[major].[minor].[patch]
.
So, with EF Core 8 now officially released, this means that for Entity Framework Extensions and Entity Framework Plus:
- Release notes will now use the format
8.x.y.z
instead of7.x.y.z
. - EF Extensions for EF6 (usually used for .NET Framework) will also adopt the new format
8.x.y.z
to maintain consistency with EF Core versioning.
The 8
corresponds to the highest EF Core stable version available, so EF Core 8.
Bulk Insert Optimized
A new method named BulkInsertOptimized is now part of Entity Framework Extensions.
You can use this method like you are using BulkInsert. The main advantage is the BulkInsertOptimized
method doesn't output value by default.
context.BulkInsertOptimized(customers);
Another key benefit of the BulkInsertOptimized
method is its ability to suggest improvements for optimal performance, ensuring the use of BulkCopy
into the destination table.
Learn more about BulkInsertOptimized
BulkOperationOptions
Passing bulk options to a bulk extensions method is now available via variable.
Previously, you were able to pass options only through a fluent API:
context.BulkInsert(invoices, options => { options.IncludeGraph = true });
You can now pass options by creating a new Z.BulkOperations.BulkOperationOptions
instance, such as:
// CREATE bulkOptions instance var bulkOptions = context.Invoices.CreateBulkOptions(); // SET Options bulkOptions.IncludeGraph = true; bulkOptions.BatchTimeout = 180; // CALL a bulk method context.BulkInsert(invoices, bulkOptions);
Learn more about bulk options
Bulk Insert with IncludeGraph - Faster & Lighter
In 2023, we were mainly focused on improving our bulk method. We made a lot of improvements to our Include Graph options to make sure it's faster and lighter, and so far, all we can say is this has been a success.
As you can see in our IncludeGraph - Breaking Changes article, the new IncludeGraph
option can be 5 times faster and consume around only 20% of the memory compared to its predecessor that you can still access with the LegacyIncludeGraph
option.
100k invoices, 500k InvoiceItem:
IncludeGraph | LegacyIncludeGraph | SaveChanges | |
---|---|---|---|
Memory | 400 MB | 2000 MB | 1800 MB |
Performance | 10s | 48s | 58s |
Bulk Insert with Complex Type
EF Core 8 added the long waiting complex type previously available from EF 6. We are happy to announce that our Bulk Insert and most other bulk methods already support complex and nested complex types.
Bulk inserting an entity with a complex type doesn't require any additional setup on your side. You simply use the BulkInsert
method as you usually do:
context.BulkInsert(entitiesWithComplexType);
You can learn more about complex types on Learn EF Core:
Conclusion
In conclusion, upgrading to EF Core 8 presents its challenges, but with our Entity Framework Extensions that already fully support it, you can now feel safe to start to upgrade your projects.
Our primary objective in 2023 was to enhance performance and reduce memory consumption, and we are proud of the improvements we have made. Looking ahead to 2024, our team is already preparing to support the first alpha release of EF Core 9. We will dedicate more time to improving our documentation and introducing new features, both free and premium, to provide further flexibility to developers.
ZZZ Projects