0
public void ConfigureServices(IServiceCollection services)
{       
    services.AddTransient<IUserService, UserService>();
    services.AddControllersWithViews();
    services.AddOptions();
    services.AddMvc();
}

An error occurred while starting the application. AggregateException: Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: DataServiceLayer.OperationInfrastructure.IUserService Lifetime: Transient ImplementationType: DataServiceLayer.OperationService.UserService': Unable to resolve service for type 'DataAccessLayer.Operation.IUsersRepository' while attempting to activate 'DataServiceLayer.OperationService.UserService'.)

Steven
  • 166,672
  • 24
  • 332
  • 435

1 Answers1

1

You must add to Startup.cs file your Repository lifecycle too.

For example:

services.AddTransient<IUserRepository, UsersRepository>();
Steven
  • 166,672
  • 24
  • 332
  • 435
Ali Alizade
  • 113
  • 1
  • 4