Menu

Register Dependencies in ASP.NET Core app

Since asp.net is new and its bit of a learning curve, where and how you do certain things. I used Unity, TinyIoC, Ninject in the past. But ASP.NET Core includes a simple built-in container.

in your Startup.cs file, find the section called ConfigureServices(IServiceCollection services)

public void RegisterRepositoryDependencies(IServiceCollection services)
{
  services.AddSingleton<IQuestionRepository, QuestionRepository>();
}

Now your Controllers you can use the dependencies.

Leave a comment