Chapter 5: Setting Up DbContext and Controllers

Routing and controllers are responsible for receiving, validating, and processing incoming HTTP requests. During the processing, the controllers may or may not persist and read records in the database through DbContext. Learning how a controller and DbContext work together is essential in building web application projects that work as expected.

At the end of this chapter, you will be able to understand the following topics:

  • Writing entities and enums
  • Setting up a database, EF Core, and DbContext
  • Writing controllers and routes
  • Testing controllers with Swagger UI

Technical requirements

Here is what you need to complete this chapter:

  • Visual Studio 2019, Visual Studio for Mac, or Rider
  • The dotnet-ef ...

Get ASP.NET Core and Vue.js now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.