Creating Web APIs with ASP.NET Core 5
Jan 11, 2021 11:51 0 Comments ASP.NET Core GANESH MALLA

Prerequisites –
 Visual Studio 2019 (update version16.8) or later
 .NET 5.0 SDK or later

Design of the application –

Steps to create a Web API using ASP.NET Core 5 –
Below are the steps we will follow to create a Web API using ASP.NET Core 5.
 From the File menu, select New -> Project.
 Select the ASP.NET Core Web Application template and click Next.
 Give a name to the project and click Create.
 A new ASP.NET Core Web Application dialog will open, make sure that .NET
Core and ASP.NET Core 5.0 are selected.
 Select the API template and click Create.

Add a database context class
Add NuGet packages by following below steps –
1. From the Tools menu, select NuGet Package Manager > Manage NuGet Packages for Solution.
2. Select the Browse tab, and then enter Microsoft.EntityFrameworkCore.SqlServer in the search box.
3. Select Microsoft.EntityFrameworkCore.SqlServer in the left pane.
4. Select the Project check box in the right pane and then select Install.
5. Use the preceding instructions to add
the Microsoft.EntityFrameworkCore.InMemory NuGet package.
 Register the database context
 Add a controller by following below steps –
1. Right-click the Controllers folder.
2. Select Add -> New Scaffolded Item.
3. Select API Controller with actions, using Entity Framework, and then select Add.
4. In the Add API Controller with actions, using Entity Framework dialog:
i. Select your Model in the Model class option.
ii. Select your data context class in the Data context class option.
iii. Select Add.


Prev Next
About the Author
Topic Replies (0)
Leave a Reply
Guest User

You might also like

Not sure what course is right for you?

Choose the right course for you.
Get the help of our experts and find a course that best suits your needs.

Let`s Connect