News

Entity Framework 7 Preview 7 Adds & Improves Interceptors

Entity Framework 7 Preview 7 is all about Interceptors, used for working with EF Core operations.

Interceptors enable interception, modification and/or suppression of EF Core operations, such as low-level database operations to execute a command and higher-level operations like calls to SaveChanges.

"Interceptors support async operations and the ability to modify or suppress operations, making them more powerful than traditional events, logging, and diagnostics," Microsoft said this week in announcing the preview. While Interceptor functionality is somewhat similar to that of events in terms of reacting to what EF Core is doing, they also let developers change the behavior of EF by suppressing or replacing actions that EF was going to perform, or by modifying or replacing action results. They can even perform async database access, such as changing complete database commands.

For this dev cycle, following general EF Core themes on the Themes of .NET site, the team introduced support for several new interceptors and improved existing interceptors.

EF Core Themes
[Click on image for larger view.] EF Core Themes (source: Microsoft).

Among the new Interceptor offerings is IMaterializationInterceptor, which can change or replace the entity instance before and after an entity instance is created, and before and after properties of that instance are initialized.

The post goes into detail about LINQ expression tree interception, optimistic concurrency interception and more, explaining how it can sometimes take an enormous amount of code to accomplish a simple task like making a change to a query.

"This brings us to a critical point about interceptors," Microsoft said. "Always ask yourself if there is an easier way of doing what you want. Interceptors are powerful, but it's easy to get things wrong. They are, as the saying goes, an easy way to shoot yourself in the foot."

Existing interceptors that were enhanced in this preview include:

EF7 also includes new traditional .NET events for:

While Interceptor discussion dominates the announcement post, other improvements include:

EF Core Voting
[Click on image for larger view.] EF Core Voting (source: Microsoft).

Going forward, Microsoft will continue work in preparation for a General Availability release expected in November. The dev team collects feedback from feature requests that are voted on by developers in the project's GitHub repo. Top feature requests are illustrated in the graphic above.

Microsof'ts "Plan for Entity Framework Core 7.0" indicates large investments in EF7 will fall mainly under the following themes:

  • Highly requested features
  • NET platforms and ecosystem
  • Clear path forward from EF6
  • Performance

This week Microsoft also shipped .NET 7 Preview 7 and Visual Studio 2022 17.3.

About the Author

David Ramel is an editor and writer at Converge 360.

comments powered by Disqus

Featured

  • VS Code 1.123 Adds Agent Session Sync, 1M Context Windows

    Microsoft released Visual Studio Code 1.123 on June 3, adding agent-focused features, larger model context support, integrated browser updates and a new delay for some automatic extension updates.

  • Copilot Billing Shock Hits Developers

    Developer complaints about GitHub Copilot's new usage-based billing model have centered on unexpectedly rapid AI credit consumption, and neither GitHub nor Microsoft has responded directly to the backlash, though they have previously published guidance to lessen model usage costs.

  • Hands On with GitHub Copilot App Technical Preview: Turning a Blazor Issue into a PR

    GitHub's brand-new Copilot desktop app, in technical preview, handled a small Blazor issue from planning through pull request creation, but the hands-on test also showed why developers still need to verify agent work in the running app before merging.

  • At Build 2026, Microsoft Sets Up Windows as an OS for AI Agents

    Microsoft's Build 2026 Windows developer announcements point to a broader platform strategy for agentic AI, spanning terminal workflows, local models, app-building skills, Cloud PCs and operating system-level containment.

Subscribe on YouTube