Unable to resolve service for type while attempting to activate

后端 未结 7 940
春和景丽
春和景丽 2020-12-09 02:22

I have one file Repository.cs that contains an interface and its implementation like so:

public interface IRepository

{
    IEnumerable

        
7条回答
  •  执笔经年
    2020-12-09 02:54

    You have to add your implementation to DI (Dependeny Injection) section. For .Net Core Mvc, it would be like this:

     public void ConfigureServices(IServiceCollection services)
     {
       services.AddDbContext(options =>
        options.UseInMemoryDatabase()
       );
       services.AddScoped();
    
     }
    

提交回复
热议问题