Next, add controllers for TahDoList and TahDoItem.
- In the Solution Explorer, right-click the Controllers folder and select Add | Controller. The Add Controller dialog box opens.
- Enter a Controller name, for example, TahDoListController.
- Under Template in the Scaffolding options box, select Controller with read/write actions and views, using Entity Framework.
- Under Model class, select TahDoList (TahDo.Models), which is the strongly typed class you want a model for.
- Under Data context class, select <New data context…>. The New Data Context dialog box opens.
- Click OK and then click Add.Visual Studio generates everything you need, including controllers and views for all of the CRUD operations against our model. Links to the Entity Framework for data access have also been automatically created.
- You can also add a controller in the same way for a TahDoItemController. Follow steps 1-6 using TahDoItemController for the name and TahDoItem (TahDo.Models) for the Model class.
Now run the project to dynamically create a database and add new items.