title: Unable to resolve service for type 'Core.Data.CoreContext' while attempting to activate 'Core.Data.Repositories.UnitOfWork'
body: <p>I have part of WebAPI application that I want to move to separate project as class library.
  It is common base structure that almost every app has so idea is to make it easy shareable.
  Application type is:
  ASP.NET Core Web Application / .NET Framework - ASP.NET Core 2.0 / Web API</p>
  
  <p>What I have done in that direction is created a project named Core and moved those shared elements there, including Base Entities (e.g. User, Settings, etc), CoreContext, UnitOfWork, Generic Repository, BaseRepositories,...</p>
  
  <p>In the Main project of app there are others Entities, AppContext that inherits CoreContext, more Repositories, and all Controllers, ...</p>
  
  <p>I was able to build the app but when starting it get the following error:</p>
  
  <blockquote>
    <p>InvalidOperationException: Unable to resolve service for type 'Core.Data.CoreContext' while attempting to activate 'Core.Data.Repositories.UnitOfWork'.</p>
    
    <p>Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateArgumentCallSites(Type
    serviceType, Type implementationType, ISet callSiteChain,
    ParameterInfo[] parameters, bool throwIfCallSiteNotFound)...</p>
  </blockquote>
  
  <p>Problem seems to be that <code>UnitOfWork</code> class is in Core project and in Main project is <code>Startup.cs</code> with method <code>ConfigureServices</code> that has <code>services.AddTransient&lt;IUnitOfWork, UnitOfWork&gt;();</code>.</p>
  
  <p>Is this a bug or am I just not configuring it correctly and how could it be achieved, if possible at all?</p>
  
  <p>*Further technical details:<br>
  NetCore &amp; EF Core version: 2.0<br>
  Database Provider: Microsoft.EntityFrameworkCore.SqlServer<br>
  IDE: Visual Studio 2017 15.3<br>
  Operating system: Windows 10<br></p>
  
  <p>UPDATE: Code Sample</p>
  
  <pre><code>namespace Main
  {
      public class Program
      {
          public static void Main(string[] args)
          {
              BuildWebHost(args).Run();
          }
  
          public static IWebHost BuildWebHost(string[] args) =&gt;
              WebHost.CreateDefaultBuilder(args).UseStartup&lt;Startup&gt;().Build();
      }
      public class Startup
      {
          public Startup(IConfiguration configuration)
          {
              Configuration = configuration;
          }
          public IConfiguration Configuration { get; }
  
          public void ConfigureServices(IServiceCollection services)
          {
              services.AddTransient&lt;IUnitOfWork, UnitOfWork&gt;();
              services.AddMvc();
              var conn = Configuration.GetConnectionString("DefaultConnection"); 
              services.AddDbContext&lt;AppContext&gt;(options =&gt; options.UseSqlServer(conn));
          }
      }
  }
  
  namespace Main.Data
  {
      public class AppContext : CoreContext
      {
          ...
      }
  }
  </code></pre>
  
  <p>-</p>
  
  <pre><code>namespace Core.Data
  {
      public class UnitOfWork : IUnitOfWork, IDisposable
      {
          public CoreContext context;
  
          public UnitOfWork(CoreContext context)
          {
              this.context = context;
          }
  
          public T Get&lt;T&gt;() where T : BaseRepository, new()
          {
              var repository = new T();
              repository.Init(context);
              return repository;
          }
  
          public void Dispose()
          {
              Dispose(true);
              GC.SuppressFinalize(this);
          }
      }
  }
  </code></pre>