I have one file Repository.cs
that contains an interface and its implementation like so:
public interface IRepository
{
IEnumerable
You need to register IRepository
with the Dependency Injection framework. For example, in ConfigureServices
, add the following:
services.AddScoped<IRepository, MemoryRepository>();
AddScoped
is just one example of a service lifetime. Note that:
Scoped lifetime services are created once per request.
See the docs for more information on Dependency Injection in ASP.NET Core.