title: how to configure dependencies in asp.net core
body: <p>I have an ASP.Net Core 2.1 application. I need to register &amp; inject few dependencies of <code>AWS</code>.</p>
  
  <p>Currently, the implementation looks like this:</p>
  
  <pre><code>public abstract class BaseService
  {
      protected readonly IConfiguration _configuration;
      protected readonly RegionEndpoint _region;
      protected readonly IAmazonDynamoDB _dynamoClient;
      protected  IPocoDynamo _pocoDynamo;
  
      public BaseService(IConfiguration configuration)
      {
          _configuration = configuration;
          var awsSettings = configuration.GetSection("AWS");
          _dynamoClient = SetDynamoClient(awsSettings);
          _pocoDynamo = SetPocoDynamoClient();
      }
  
      protected IAmazonDynamoDB SetDynamoClient(IConfigurationSection configuration)
      {
          AWSCredentials credentials = new BasicAWSCredentials(configuration["AccessKey"], configuration["AccessSecret"]);
          return new AmazonDynamoDBClient(credentials, _region);
      }
  
      protected IPocoDynamo SetPocoDynamoClient()
      {
          return new PocoDynamo(_dynamoClient);
      }
  }
  </code></pre>
  
  <p>While unit testing, AWS services can't be mocked due to this. </p>
  
  <p>I want to register all these dependencies in <code>Startup.cs</code> in <code>ConfigureServices()</code></p>
  
  <p>This is what I was trying:</p>
  
  <pre><code>public void ConfigureServices(IServiceCollection services)
  {
      AWSCredentials credentials = new BasicAWSCredentials(configuration["AccessKey"], configuration["AccessSecret"]);
  
      services.AddTransient(IAmazonDynamoDB, (a) =&gt;
           {
               return new AmazonDynamoDBClient(credentials, RegionEndpoint.GetBySystemName(""))
           });
      // here I need to pass the IAmazonDynamoDB to below IOC
      // services.AddSingleton&lt;IPocoDynamo,new PocoDynamo()&gt; ();
  
      return services;
  }
  </code></pre>
  
  <p>But this is throwing an error </p>
  
  <blockquote>
    <p>Error CS0119  'IAmazonDynamoDB' is a type, which is not valid in the given context</p>
  </blockquote>
  
  <p>How to configure dependencies as required here?</p>
  
  <p>Thanks!</p>