.Net core1.0 Error trying to activate my repository
<p>I've created a solution which includes an MVC project and 2 .net core class library projects. 1 for the service layer and 1 for the repository layer. I have successfully wired the interfaces through the layers. but at the point in program class when it tries to perform <code>host.Run();</code> It errors. with this:
<code>InvalidOperationException: Unable to resolve service for type 'VisualRepository.VisualJobsDbContext' while attempting to activate 'VisualRepository.RecruiterRepository'.</code></p>

<p>This is the start of my DBcontext Class: </p>

<pre><code>public partial class VisualJobsDbContext : DbContext
{
    private IConfigurationRoot _config;

    public VisualJobsDbContext() { }

    public VisualJobsDbContext(IConfigurationRoot config, DbContextOptions options) : base(options)
    {
        _config = config;
    }
    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
    {
        base.OnConfiguring(optionsBuilder);

        optionsBuilder.UseSqlServer(_config["ConnectionStrings:VisualJobsContextConnection"]);
    }
</code></pre>

<p>This is the start of my Recruiter Repository</p>

<pre><code>public class RecruiterRepository : GenericRepository&lt;VisualJobsDbContext,Agent&gt;, IRecruiterRepository
{
    private VisualJobsDbContext _context;

    public RecruiterRepository(VisualJobsDbContext context) : base(context)
    {
        _context = context;

    }
</code></pre>

<p>both of these sit in the repository layer and I suspect its failing because I haven't set either of these to <strong>'New'</strong> anywhere.</p>

<p>Up in the startup class of the MVC project in the ConfigureServices method I have:</p>

<pre><code> services.AddSingleton(_configuration);
        // Add framework services.
        services.AddApplicationInsightsTelemetry(_configuration);

        services.AddLogging();
        services.RegisterServices();

        services.AddMvc();
</code></pre>

<p>Where Services.RegisterServices is a method in the service layer that registers my interfaces into the di container including adding the repository container.
I suspect I need to register VisualJobsDBContext in the mvc layer somehow, but I was hoping that I could keep it registered in the repository layer some how since I dont want a direct connection through to this layer from MVC. Can anybody point me in a sample of how to register the my repositories in the repository layer.</p>

<p>In my Repository Layer when I register my interfaces I currently have the following code :  </p>

<pre><code>public static class RepositoryCollectionExtensions
{
    public static IServiceCollection RegisterRepositoryServices(this IServiceCollection services)
    {
        services.AddScoped&lt;IRecruiterRepository, RecruiterRepository&gt;();

        return services;
    }
}
</code></pre>

<p>so I was hoping I could do something here such as services.AddDbContext(.... but I cant seem to get the signature right.</p>