Register classes with primitive dependencies in ASP NET Core
<p>I got baffled on how can i resolve connection string dependency on <code>UserRepo</code> once it is injected on an mvc controller by ASP NET Core's DI? Note that my repo is targeting NET 4.6. and uses either sql db with dapper orm. Tips and advice will do.</p>

<p>Heres the code.</p>

<p>Interface to be depended</p>

<pre><code>public interface IUserRepo
{
  List&lt;User&gt; GetAll();
}
</code></pre>

<p>Concrete class that will be injected to mvc controller and has its own dependency</p>

<pre><code>public class UserRepo: IUserRepo
{
   private string connectionString = "";

   //Depends on a connectionstring
   public UserRepo(string connectionString)
   {
      this.connectionString  = connectionString;
   }

   public  List&lt;User&gt; GetAll()
   {
      //create an sqlconnection using provided  connectionstring
      //return list from db...
   }
}
</code></pre>

<p>on ASP MVC CORE's startup.cs </p>

<pre><code>public void ConfigureServices(IServiceCollection services)
{ 
   services.AddMvc();
   //inject UserRepo , how to resolve UserRepo's dependency?
   services.AddScoped&lt;IUserRepo, UserRepo&gt;();
}
</code></pre>