Discover What's New in EF Core 10

Entity Framework Core 10 (EF10) is the latest evolution of Microsoft's ORM, bringing significant enhancements to database interactions, especially with Azure Cosmos DB, LINQ translations, and update operations. In this article, we’ll explore the key features that make EF10 a game-changer for .NET developers. Enhanced Azure Cosmos DB Support EF10 introduces new capabilities for Azure Cosmos DB: Full-Text Search Integration : Cosmos DB now supports full-text search, allowing for efficient querying of text content directly in EF10. This is especially useful for AI-driven applications where relevance and search optimization are crucial. public class Blog { public string Contents { get; set; } } public class BloggingContext : DbContext { protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.Entity(b => { b.Property(x => x.Contents).EnableFullTextSearch(); b.HasIndex(x => x.Contents).IsFullTextIndex(); }); } } var results = await context.Blogs.Where(x => EF.Functions.FullTextContains(x.Contents, "cosmos")).ToListAsync(); Hybrid Search Capabilities : Leveraging RRF (Reciprocal Rank Fusion), EF10 now enables hybrid search, blending full-text search with vector-based searches for more accurate results. float[] myVector = /* vector data */; var hybridResults = await context.Blogs.OrderBy(x => EF.Functions.Rrf( EF.Functions.FullTextScore(x.Contents, "database"), EF.Functions.VectorDistance(x.Vector, myVector) )).Take(10).ToListAsync(); Vector Similarity Search Maturity : The experimental vector search feature from EF9 is now fully supported in EF10, with improvements for owned reference entities. New LINQ Operators for Joins .NET 10 simplifies LINQ joins with native LeftJoin and RightJoin methods. Previously, these joins required complex combinations of SelectMany and GroupJoin. Now, they are much more intuitive: var query = context.Students .LeftJoin( context.Departments, student => student.DepartmentID, department => department.ID, (student, department) => new { student.FirstName, student.LastName, Department = department.Name ?? "[NONE]" }); Simplified Update Operations EF10 introduces an easier way to perform updates with ExecuteUpdateAsync, supporting lambda expressions directly: await context.Blogs.ExecuteUpdateAsync(s => { s.SetProperty(b => b.Views, 8); if (nameChanged) { s.SetProperty(b => b.Name, "Updated Blog Name"); } }); This eliminates the need for cumbersome expression trees, making code cleaner and more maintainable. Final Thoughts EF Core 10 is set to make database interactions smoother and more efficient. Its enhancements in Cosmos DB support, LINQ simplifications, and update handling will undoubtedly be welcomed by .NET developers. Stay tuned for deeper dives into each of these features in upcoming tutorials.

May 17, 2025 - 08:08
 0
Discover What's New in EF Core 10

Entity Framework Core 10 (EF10) is the latest evolution of Microsoft's ORM, bringing significant enhancements to database interactions, especially with Azure Cosmos DB, LINQ translations, and update operations. In this article, we’ll explore the key features that make EF10 a game-changer for .NET developers.

Enhanced Azure Cosmos DB Support

EF10 introduces new capabilities for Azure Cosmos DB:

  1. Full-Text Search Integration : Cosmos DB now supports full-text search, allowing for efficient querying of text content directly in EF10. This is especially useful for AI-driven applications where relevance and search optimization are crucial.
 public class Blog
{
    public string Contents { get; set; }
}

public class BloggingContext : DbContext
{
    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        modelBuilder.Entity(b =>
        {
            b.Property(x => x.Contents).EnableFullTextSearch();
            b.HasIndex(x => x.Contents).IsFullTextIndex();
        });
    }
}

var results = await context.Blogs.Where(x => EF.Functions.FullTextContains(x.Contents, "cosmos")).ToListAsync();
  1. Hybrid Search Capabilities : Leveraging RRF (Reciprocal Rank Fusion), EF10 now enables hybrid search, blending full-text search with vector-based searches for more accurate results.
 float[] myVector = /* vector data */;
var hybridResults = await context.Blogs.OrderBy(x => EF.Functions.Rrf(
    EF.Functions.FullTextScore(x.Contents, "database"),
    EF.Functions.VectorDistance(x.Vector, myVector)
)).Take(10).ToListAsync();
  1. Vector Similarity Search Maturity : The experimental vector search feature from EF9 is now fully supported in EF10, with improvements for owned reference entities.

New LINQ Operators for Joins

.NET 10 simplifies LINQ joins with native LeftJoin and RightJoin methods. Previously, these joins required complex combinations of SelectMany and GroupJoin. Now, they are much more intuitive:

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

Simplified Update Operations

EF10 introduces an easier way to perform updates with ExecuteUpdateAsync, supporting lambda expressions directly:

 await context.Blogs.ExecuteUpdateAsync(s =>
{
    s.SetProperty(b => b.Views, 8);
    if (nameChanged)
    {
        s.SetProperty(b => b.Name, "Updated Blog Name");
    }
});

This eliminates the need for cumbersome expression trees, making code cleaner and more maintainable.

Final Thoughts

EF Core 10 is set to make database interactions smoother and more efficient. Its enhancements in Cosmos DB support, LINQ simplifications, and update handling will undoubtedly be welcomed by .NET developers. Stay tuned for deeper dives into each of these features in upcoming tutorials.