Skip to content
  • English Deutsch

benjamin-abt.com

Performance is a feature | Cloud - AI - Azure - .NET - Sustainability

  • Home
  • Blog
  • Portfolio
    • Overview
    • Workshops & Training
    • Publications
  • Contact
  • Home
  • Blog

Difference between Add and AddAsync in EF Core

Difference between Add and AddAsync in EF Core
January 4, 2023 2 min read BEN ABT
.NET EF Core

This article was written in 2023. Versions, tools and recommendations may have changed since then. Newer posts are collected under .NET.

Using Add or AddAsync in Entity Framework Core can be a little confusing, especially for those new to working with databases and ORMs (Object-Relational Mappers). In this blog post, we’ll take a look at the difference between Add and AddAsync and when you might want to use one over the other.

First, let’s define what these two methods do. Add is a method on the DbSet class in Entity Framework Core that is used to add a new entity to the database. It is a synchronous method, meaning that it will block the calling thread until the operation is complete. AddAsync, on the other hand, is an asynchronous version of Add that allows you to add a new entity to the database without blocking the calling thread.

So, when should you use Add versus AddAsync? In general, an async method should use be used whenever you are working with an application that relies on asynchronous programming, such as a web application or a mobile app. This is because an async implementation allows your application to remain responsive while the database operation is being performed.

It’s also worth noting that (here) AddAsync is not always faster than Add. In fact, in some cases, AddAsync may actually be slower due to the overhead of starting and managing the asynchronous task. After all, the state machine costs performance in principle. However, the advantages outweigh the disadvantages in almost all cases.

Under the hood of Add and AddAsync

The special feature of Add or AddAsync is that there are additional features that are not obvious at first glance.
The fact that a method is offered as Async implies that a network call is made. But this is not the case with Add, is it? Yes, a network call can be made, namely when using certain value generators. The docs of AddAsync(Object, CancellationToken) Method says:

This method is async only to allow special value generators, such as the one used by ‘Microsoft.EntityFrameworkCore.Metadata.SqlServerValueGenerationStrategy.SequenceHiLo’, to access the database asynchronously. For all other cases the non async method should be used.

In summary, the use of Async in this case is only recommended if the feature of value generators , which causes database network roundtips, is actively used. For all other cases, the non-asynchronous way via Add should be used, as recommended by the documentation (current status).

In case of doubt, however, AddAsync can be used here as well without any problems. Even if the feature of Value Generators is not used it is not worse than vice versa.

Related articles

Advanced Usage of MSSQL Indexed Views in EF Core

Jan 13, 2025 - 5 min read

Advanced Usage of MSSQL Indexed Views in EF Core

In the world of Microsoft SQL Server , views are a powerful tool for simplifying complex data queries. Simple views offer no real …

Increase Command Timeout for EF Core Migration Bundles

Jan 3, 2025 - 2 min read

Increase Command Timeout for EF Core Migration Bundles

EF Core Migration Bundles are standalone executable files that contain one or more Entity Framework Core migrations and can be applied …

New Data Annotation attributes with .NET 8

Nov 19, 2023 - 2 min read

New Data Annotation attributes with .NET 8

With .NET 8, the System.ComponentModel.DataAnnotations Namespace has been revised and some new attributes have been added that have been …


BEN ABT

BEN ABT

Ben is Chief Engineering Officer and Principal Software Engineer at Medialesson.de, with a strong focus on .NET and Microsoft Azure. In his professional role, he designs and builds highly scalable platforms for hybrid and cloud-based scenarios. He also advises companies and C-levels on migrating to the sovereign cloud.

He runs myCSharp.de, the largest and most active German-speaking C# community forum, actively contributes to both his own and external open-source projects and regularly shares his knowledge through his blog, at community events, conferences and as a writer for technical magazines.

Let's Work Together

Looking for an experienced Platform Architect or Engineer for your next project? Whether it's cloud migration, platform modernization or building new solutions from scratch - I'm here to help you succeed.

New Platforms

Modernization

Training & Consulting

Contact Me
X Facebook LinkedIn WhatsApp
Back Next Blog Post

Open for work!

Contact Me
BEN ABT BEN ABT Software Engineer · Microsoft MVP Passionate about .NET, Azure, performance optimization and sustainable software engineering.

Medialesson GmbH Logo

Microsoft MVP Logo

Recent posts

View all
Stop Using nginx as Your Default Static File Server in Docker

Stop Using nginx as Your Default Static File Server in …

Oct 24, 2026
Containerizing .NET in 2026 Without a Dockerfile

Containerizing .NET in 2026 Without a Dockerfile

Oct 20, 2026
Problem Details in ASP.NET Core and .NET 11

Problem Details in ASP.NET Core and .NET 11

Oct 5, 2026
Resilience in .NET with Microsoft.Extensions.Resilience

Resilience in .NET with Microsoft.Extensions.Resilience

Sep 21, 2026
What Matters in ASP.NET Core 11

What Matters in ASP.NET Core 11

Sep 14, 2026

Tags

.NET (192) Csharp (96) ASP.NET Core (48) Azure (41) DevOps (17) Docker (14) Microsoft (14) EF Core (11) Microsoft MVP (11) AI (10) GitHub (10) GitHub Copilot (10) ASP.NET (9) Security (9) Synology (9) Architecture (8) Raspberry (8) Azure Functions (7) Cloudflare (7) Bicep (6)
benjamin-abt.com

About BEN

Benjamin Abt is a Software Engineer, Platform Architect and Microsoft MVP specializing in .NET, Azure, cloud architecture, performance optimization and sustainable software development.

Connect

  • Follow me on GitHub
  • Follow me on LinkedIn
  • Follow me on Mastodon
  • Microsoft MVP profile
  • Follow SchwabenCode on GitHub
  • Follow me on X

Quick Links

  • Portfolio
  • Blog
  • Workshops & Training
  • Publications
  • Get in Touch
  • Sitemap
Open for Work

© Copyright Benjamin Abt & SchwabenCode | 2011 - 2026

Content licensed under CC BY 4.0 unless otherwise noted.

  • Impressum
  • Privacy
  • Contact