I have following repository classes:
public class TestRepository : Repository<Test>
{
private TestContext _context;
public TestRepository(TestContext context) : base(context)
{
_context = context;
}
}
public abstract class Repository<T> : IRepository<T> where T : Entity
{
private TestContext _context;
public Repository(TestContext context)
{
_context = context;
}
...
}
public interface IRepository<T>
{
...
}
How do I implement the dependency injection in ASP.NET Core in my Startup.cs?
I implemented it like this:
services.AddScoped(typeof(IRepository<>), typeof(Repository<>));
But then I get following error:
Cannot instantiate implementation type 'Test.Domain.Repository
1[T]' for service type 'Test.Domain.IRepository1[T]'.