Introduction
This article explains the scaffolding of asynchronous Web API 2 Controllers. For this we need Visual Studio 2013. For scaffolding the controller we need to select the "Web API 2 Controller with actions, using Entity Framework". For scaffolding asynchronous Web API controllers use the "use async controller actions" check box that is for scaffolding an asycnchronous Controler in Web API 2.
Now we will explain scaffolding. Scaffolding is just used for automatically generating code in a web application. Visual Studio 2013 has a preinstalled code generator for the Web API. Scaffolding generates the code including the data model class.
- Use the following procedure to create a Web API application using Visual Studio 2013.
- Start Visual Studio 2013.
- Select "Installed" -> "Web".
- From the Template window select "ASP.NET Web Application".
- Click the "OK" button.

- From the ASP.NET Project Window select "Web API".

- Click on the "OK" button.
- Now we add the Scaffolding Item to the Web API.
- In the "Solution Explorer".
- Right-click on the "Controller" -> "Add" -> "New Scaffold Item".

- Open the Scaffold Window to select the type of scaffold, here we select "Web API".

- From "Add Controller" enter the name of the Controller as "ItemsController" and select the check box "Use async controller actions".

- Now select the "Model class" and "New Data Context".

- After clicking on the "OK" button see the Solution Explorer; there are two files, the first is "ItemsController.cs" in the Controller Folder and the other is "ScaffoldAsyncContext.cs" in the Model Folder.

- Now we open the ItemsController.cs class. We can see that there is some auto-generated code that is inherited from the Model class "Item".
See the following code:

Jesse ButlerPosted Sep 17, 2022, 1:39 AM
So why are the "GetItems" and "ItemExists" methods not async? They make calls to the DbContext, which potentially makes calls to the database. Also "GetItem" is async, but not "GetItems".