New Features in EF Core 10
Ali Shahriari (MasterPars)

Ali Shahriari (MasterPars) @masterpars

About: I am a backend developer specialized in building scalable, high-performance platforms. My work primarily focuses on platform development, seamless integration with external systems, and ensuring high

Location:
Shiraz, Iran
Joined:
Sep 22, 2024

New Features in EF Core 10

Publish Date: May 19
1 0

Entity Framework Core 10 (EF10) introduces several powerful features aimed at enhancing performance, flexibility, and integration capabilities with modern data systems. In this article, we will explore the key features introduced in EF Core 10 and how they can be leveraged to optimize application development.


🌐 Azure Cosmos DB for NoSQL

One of the major enhancements in EF10 is the improved support for Azure Cosmos DB for NoSQL, enabling efficient database operations and powerful new capabilities:

1- Full-text search support:

  • Allows high-performance text search directly on Cosmos DB documents.
  • Supports functions like FullTextContains, FullTextContainsAll, and FullTextContainsAny.

Example:

var results = await context.Blogs.Where(x => EF.Functions.FullTextContains(x.Content, "EF Core 10"))
                                .ToListAsync();
Enter fullscreen mode Exit fullscreen mode

2- Hybrid search with Vector Similarity:

  • EF10 now supports Reciprocal Rank Fusion (RRF), combining vector similarity and full-text search for hybrid queries.

Example:

float[] myVector = {0.1f, 0.2f, 0.3f};
var results = await context.Blogs.OrderBy(x => EF.Functions.Rrf(
    EF.Functions.FullTextScore(x.Content, "database"),
    EF.Functions.VectorDistance(x.Vector, myVector)))
.Take(10)
.ToListAsync();

Enter fullscreen mode Exit fullscreen mode

🔍 LINQ and SQL Translation Enhancements

EF Core 10 introduces native support for new LINQ operators introduced in .NET 10:

1- LeftJoin and RightJoin Support:

  • Simplifies complex join queries in LINQ.

Example:

var query = context.Students
    .LeftJoin(context.Departments,
             student => student.DepartmentID,
             department => department.ID,
             (student, department) => new
             {
                 student.FirstName,
                 student.LastName,
                 Department = department.Name ?? "[NONE]"
             });

Enter fullscreen mode Exit fullscreen mode

⚡ ExecuteUpdateAsync Enhancements

ExecuteUpdateAsync now supports regular, non-expression lambdas, simplifying update logic:

Example:

await context.Blogs.ExecuteUpdateAsync(s =>
{
    s.SetProperty(b => b.Views, 100);
    s.SetProperty(b => b.Name, "Updated Blog Name");
});
Enter fullscreen mode Exit fullscreen mode

This change eliminates the complexity of building expression trees manually, making bulk updates more readable and maintainable.


📌 Conclusion

EF Core 10 brings substantial improvements to database interactions, LINQ translations, and Cosmos DB integration. These new capabilities not only streamline development but also enhance performance and scalability for modern applications. Developers leveraging EF10 can build more efficient, data-driven applications with less code and improved readability.

Comments 0 total

    Add comment