title: Best way to inject instance of DynamoDBContext in .NET Core
body: <p>Currently working on a web services project for my class and have decided to make a web API using .NET Core and DynamodDB.</p>
  
  <p>I was just curious what the best way to inject the <code>DynamoDBContext</code> is?</p>
  
  <p>I currently am doing it like this:</p>
  
  <pre><code>public void ConfigureServices(IServiceCollection services)
  {
      services.AddMvc();
  
      services.AddDefaultAWSOptions(Configuration.GetAWSOptions());
      services.AddAWSService&lt;IAmazonDynamoDB&gt;();
  }
  </code></pre>
  
  <p>I got this piece of code above from the DynamoDB documentation. I add an instance of <code>IAmazonDynamoDB</code> to the project.</p>
  
  <pre><code>DynamoDBContext context;
  public ValuesController(IAmazonDynamoDB context)
  {
      this.context = new DynamoDBContext(context);
  }
  </code></pre>
  
  <p>In the controller, I then inject the <code>IAmazonDynamoDB</code> instance, and use that to create an instance of <code>DynamoDBContext</code>.</p>
  
  <p>Is there a way to create an instance of the context in the <code>ConfigureServices</code> method and add it to the project there, or is the way I am doing it currently fine?</p>