title: Can't add Entity Framework Core migrations to .NET Standard 2.0 project
body: <p>I've got a Solution with many projects.
  One of them (<code>Domain</code>) is a .NET Standard 2.0 project where I made my EF Core <code>DbContext</code> implementation for which I want to enable <strong>database migrations</strong>.</p>
  
  <p>I saw various blogs and Q/A forums where the problem was explained but none of the proposed solutions seem to work for me because of the .NET Core newer version or (probably) for my particular solution configuration.</p>
  
  <p><strong>Solution projects</strong></p>
  
  <ul>
  <li>Engine (.NET Core 2.1 Console App)</li>
  <li>Web API (.NET Core 2.1 Library)</li>
  <li>Application (.NET Core 2.1 Library)</li>
  <li>Domain (.NET Standard 2.0 Library)</li>
  <li>WindowsService (.NET Core 2.1 Console App)</li>
  </ul>
  
  <p>The <code>WindowsService</code> is the Startup project, where an instance of the <code>Engine</code> is created and encapsulated to run as Windows Service or Console application (for debug).</p>
  
  <p>The <code>Engine</code> is the real core application, where an instance of <code>Kestrel</code> self-host Web server is configured as Web API and instantieted. Also other components are instantiated and stay alive (UDP listener, machine watchdog, etc...).</p>
  
  <p><code>WebAPI</code> has <code>Startup</code> class but no <code>Program</code> class, since all the configuration and the Web server start is done inside <code>Engine.Program.cs</code> class.</p>
  
  <p><strong>Dependencies</strong></p>
  
  <ul>
  <li>WindowsService => Engine</li>
  <li>Engine => WebAPI</li>
  <li>WebAPI => Application, Domain</li>
  <li>Application => Domain</li>
  </ul>
  
  <p>The first attempt was to simply launch <code>add-migration Initial</code> from PMC with <code>Domain</code> project as target, but it turns to: </p>
  
  <blockquote>
    <p>Unable to create an object of type 'MyDbContext'. Add an
    implementation of 'IDesignTimeDbContextFactory' to the
    project, or see <a href="https://go.microsoft.com/fwlink/?linkid=851728" rel="nofollow noreferrer">https://go.microsoft.com/fwlink/?linkid=851728</a> for
    additional patterns supported at design time.</p>
  </blockquote>
  
  <p>Then I followed the proposed solution on <a href="https://stackoverflow.com/questions/44430963/is-ef-core-add-migration-supported-from-net-standard-library/45094760?noredirect=1#comment90535884_45094760">this</a> question, but:</p>
  
  <ol>
  <li><p><code>add-migration Initial</code> from PMC, after setting My <code>WebAPI</code> (with no <code>Program</code> class) as startup project, turns to:</p>
  
  <blockquote>
    <p>It was not possible to find any compatible framework version The
    specified framework 'Microsoft.NETCore.App', version '2.1.0' was not
    found.</p>
    
    <ul>
    <li>Check application dependencies and target a framework version installed at:
      C:\Program Files\dotnet\</li>
    <li>Installing .NET Core prerequisites might help resolve this problem:
      <a href="http://go.microsoft.com/fwlink/?LinkID=798306&amp;clcid=0x409" rel="nofollow noreferrer">http://go.microsoft.com/fwlink/?LinkID=798306&amp;clcid=0x409</a></li>
    <li>The .NET Core framework and SDK can be installed from:
      <a href="https://aka.ms/dotnet-download" rel="nofollow noreferrer">https://aka.ms/dotnet-download</a></li>
    <li>The following versions are installed:
      2.0.5 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
      2.0.6 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
      2.0.7 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
      2.0.9 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
      2.1.2 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]</li>
    </ul>
  </blockquote></li>
  <li><p><code>add-migration Initial</code> from PMC, after adding an additional target framework (<code>netcoreapp2.1</code>) to the Domain library project file, leads me to the same error as the 1st attempt.</p></li>
  <li><p><code>add-migration Initial</code> from PMC, after adding a reference to <code>Microsoft.EntityFrameworkCore.SqlServer.Design v1.1.6</code> always leads to same error as the 1st attempt.</p></li>
  </ol>
  
  <p>What should I do?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>This is the new <code>Domain.csproj</code> file after removing the unecessary libraries references.</p>
  
  <pre><code>&lt;ItemGroup&gt;
      &lt;PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.1.1" /&gt;
      &lt;PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.1.1" /&gt;
      &lt;PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.1.1" /&gt;
      &lt;PackageReference Include="Newtonsoft.Json" Version="11.0.2" /&gt;
  &lt;/ItemGroup&gt;
  </code></pre>
  
  <p>All libraries in all projects are up to date.</p>