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