Lesson 6 of 40 Data Access Intermediate 55 min

Entity Framework Core 10

In this lesson, you will learn how Entity Framework Core 10 simplifies data access in modern .NET applications. We will cover bulk operations, JSON column mapping, complex types, and migration practices that help you build cleaner and more scalable data-driven applications.

← Back to Visual Studio 2026 Tutorial Home

What you will learn

Why this matters: Entity Framework Core reduces repetitive database code and lets you work with data using strongly typed C# models. When used carefully, it improves productivity without giving up control.

Part 1: Bulk operations with ExecuteUpdate and ExecuteDelete

In earlier approaches, updating many records often required loading them into memory, modifying them one by one, and then saving the changes. EF Core 10 makes this easier with bulk operations such as ExecuteUpdateAsync and ExecuteDeleteAsync.

This allows you to update rows directly in the database without first materializing entities into memory. That can improve both performance and readability for certain tasks.

// Update without loading entities into memory
await context.Orders
  .Where(o => o.Status == "Pending" && o.CreatedAt < cutoff)
  .ExecuteUpdateAsync(s => s
    .SetProperty(o => o.Status, "Expired")
    .SetProperty(o => o.UpdatedAt, DateTime.UtcNow));
Use bulk operations when: you need to update or delete many rows based on a condition and do not need to process each entity individually in application memory.

Part 2: Working with JSON columns

Modern applications often need to store flexible structured data without creating many extra tables. JSON columns provide a convenient option for this scenario in supported relational databases.

EF Core 10 allows you to map certain complex objects to JSON columns while still querying inside them using LINQ.

public class Order
{
  public int Id { get; set; }
  public ShippingAddress Address { get; set; } // Stored as JSON
}

// Query into JSON data
context.Orders.Where(o => o.Address.Country == "US")

JSON columns are useful when a section of data belongs naturally to one entity but is still structured enough to benefit from typed access in code.

Part 3: Complex types and value objects

A complex type represents related values that belong together but do not have a separate identity of their own. This is useful for concepts such as money, addresses, dimensions, or contact details.

EF Core 10 improves support for this kind of modeling, making your domain classes cleaner and more expressive.

// Configuration
modelBuilder.Entity<Order>()
  .ComplexProperty(o => o.Money, b => {
    b.Property(m => m.Amount).HasPrecision(18, 4);
    b.Property(m => m.Currency).HasMaxLength(3);
  });
Example: A money object is a good candidate for a complex type because its amount and currency belong together conceptually and should be treated as one logical unit.

Part 4: Migration best practices

Migrations help you keep your database schema in sync with your EF Core models. They allow you to evolve the structure of your database in a controlled and repeatable way.

Practice Command
Add migration dotnet ef migrations add MigrationName
Generate SQL script dotnet ef migrations script
Apply to database dotnet ef database update
Bundle for deployment dotnet ef migrations bundle

It is usually safer to review generated migration files rather than treating them as automatic magic. Small schema changes can have major effects in production systems.

When to use each feature

Feature Best used for
ExecuteUpdate / ExecuteDelete Large set-based updates or deletes without loading entities
JSON columns Flexible structured data stored inside one table row
Complex types Value objects such as money, address, or settings
Migrations Versioning and applying database schema changes safely

A practical EF Core workflow

Step 1: Design your entity and related value objects clearly
Step 2: Configure mappings and database behavior in your model
Step 3: Add and review migrations before applying them
Step 4: Use LINQ queries thoughtfully to avoid inefficient SQL
Step 5: Use bulk operations when processing large datasets
Step 6: Test schema changes before deploying to production

Best practices

Summary

In this lesson, you learned how Entity Framework Core 10 improves data access with bulk operations, JSON column support, complex types, and migration tooling. These features help you build cleaner, more expressive, and more scalable data-driven applications in Visual Studio 2026.

In the next lesson, you will continue by exploring unit testing and see how modern testing tools work together with Visual Studio.