Registering the repositories

For ProductService, we will use built-in dependency injection support with ASP.NET Core. To do so, follow these simple steps:

  1. Open Startup.cs
  2. Add the repository in the ConfigureServices method. It should look like this:
    public void ConfigureServices(IServiceCollection services)    {       // Add framework services.       services.AddMvc();       services.AddSingleton<IProductRepository, ProductRepository>();    }

Get Building Microservices with .NET Core 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.