Getting ready

We will inject EF in the ConfigureServices method of Statup.cs. The IServiceCollection interface parameter of ConfigureServices already has some helpers for the most common libraries used in ASP.NET MVC.

This code does not exist by default in the empty project in Visual Studio's ASP.NET Core templates, but it already exists if we use a Web Application ASP.NET Core template.

After that, we will add a class that inherits from DbContext to our application to perform database operations that throw an ORM. Finally, we will create a repository layer between the application and the database persistence layer (even if all the code is physically in the same application) before configuring its life cycle.

But, first of all, let's create ...

Get ASP.NET Core MVC 2.0 Cookbook 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.