How to do it...

  1. First, let's add the MediatR Dependency Injection package in project.json. It will include the MediatR 4.0.0 package:
"MediatR.Extensions.Microsoft.DependencyInjection": "4.0.0"

We will also need the AutoMapper package to map Business models to ViewModels. We will talk about AutoMapper in more detail in Chapter 13, Views, Models, and ViewModels:

"AutoMapper.Extensions.Microsoft.DependencyInjection": "3.2.0"
  1. Next, let's add some configuration in Startup.cs:
public class Startup{  public void ConfigureServices(IServiceCollection services)  {    var connection = @"Data Source=MyServer;Initial    Catalog=CookBook;Integrated Security=True";    services.AddDbContext<CookBookContext>(    options => options.UseSqlServer(connection)); services.AddMvc(); ...

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.