title: EF Core Migrations after changing project to use DI
body: <p>I had a solution with no Dependency Injection. Poor form. However, I have changed the entire app, and it's not fully dependency injection enabled. All was good, until I had to do my first entity framework migration.</p>
  <p>In powershell, I cd to my data project, and do the usual:</p>
  <p><code>dotnet ef migrations add mymigration</code></p>
  <p>It builds, and then hits me with:</p>
  <blockquote>
  <p>Unable to create an object of type 'MyDbContext'</p>
  </blockquote>
  <p>In my root application startup, I prepare my DI for my context here:</p>
  <pre><code>services.AddDbContext&lt;MyDbContext&gt;(
     options =&gt; options.UseSqlServer(Configuration.GetValue&lt;string&gt;(&quot;Database:ConnectionString&quot;)
                      ));
  </code></pre>
  <p>The application works fine. It's just migrations, I cannot create.</p>
  <p>My context class is pretty standard:</p>
  <pre><code>   public class MyDbContext : DbContext
      {
  </code></pre>
  <p>Nothing interesting. Along with the usual modelbuilder works.</p>
  <p>Have I done something wrong? Or do I need to change how I do the migrations?</p>
  <p>My migrations folder in my data project has many migrations from the pre-DI days.
  Any help would be much appriciated.</p>