Entity controllers
Now that we have thousands of cities and hundreds of countries in our database, we need to find a way to bring this data to Angular and vice versa. As we already know from Chapter 2, Getting Ready, this role is played by the .NET controllers, so we’re going to create two of them:
CitiesController
, to serve (and receive) the cities’ dataCountriesController
, to do the same with the countries
Let’s get started.
CitiesController
Let’s start with the cities. Remember what we did when we created SeedController
? What we’re going to do now is rather similar, but this time we’ll make good use of Visual Studio’s code-generation features.
From our project’s Solution Explorer, follow these steps:
- Right-click on the
/Controllers/
folder. - Click on Add | Controller.
- Choose the Add API Controller with actions, using Entity Framework option (the last one from the...