Inject generic interface in .NET Core

You can do this by adding the below line in Startup.cs

// best practice  
services.AddTransient(typeof(IDatabaseService<>),typeof(DatabaseService<>));

Visit Here to know more about Dependency injection in ASP.NET Core

Leave a Comment