Using asynchronous operations
Asynchronous programming can help us avoid performance bottlenecks and enhance the overall responsiveness of our applications. .NET has had support for asynchronous operations since its early days, but version 4.5 took it one step further, with the introduction of the async
and await
keywords and related patterns. And, sure thing, the developers of Entity Framework Core took it in consideration when they wrote it: asynchronous operations, both for queries and for modifications.
First, let's get one thing straight: asynchronous operations are not faster than synchronous ones; in fact, they may even be slightly slower because of context switches. The real advantage is that they do not block the current thread of execution, and are therefore more suited for handling multiple simultaneous requests, such as in a web server.
Getting ready
We will be using the NuGet Package Manager to install the Entity Framework Core 1 package, Microsoft.EntityFrameworkCore
. We will...