title: Unable to create an object of type 'AppDataContext'
body: <p>I'm having some troubles setting up a migration in a WPF app. I have the <code>DbContext</code> class like this:</p>
  <pre><code>    public class AppDataContext : DbContext
  {
      public AppDataContext(DbContextOptions&lt;AppDataContext&gt; options) : base(options) { }
  
      public DbSet&lt;Capacity&gt; Capacities { get; set; }
      public DbSet&lt;CapacityType&gt; CapacityTypes { get; set; }
  }
  </code></pre>
  <p>Then in the App.xaml.cs I set up DI and IoC:</p>
  <pre><code>    public partial class App : Application
  {
      public IServiceProvider ServiceProvider { get; private set; }
      public IConfiguration Configuration { get; private set; }
  
      private void OnStartUp(object sender, StartupEventArgs e)
      {
          var ConfigBuilder = new ConfigurationBuilder()
              .SetBasePath(Directory.GetCurrentDirectory())
              .AddJsonFile(&quot;appsettings.json&quot;, optional: false, reloadOnChange: true);
  
          Configuration = ConfigBuilder.Build();
  
          ServiceCollection Services = new ServiceCollection();
          ConfigureServices(Services);
          ServiceProvider = Services.BuildServiceProvider();
  
          MainWindow MainWindow = ServiceProvider.GetService&lt;MainWindow&gt;();
          MainWindow.Show();
      }
  
      private void ConfigureServices(IServiceCollection Services)
      {
          Services.AddDbContext&lt;AppDataContext&gt;(options =&gt;
          {
              options.UseSqlServer(Configuration.GetConnectionString(&quot;ProdToolDb&quot;));
          });
  
          Services.AddSingleton&lt;MainWindow&gt;();
      }
  
  }
  </code></pre>
  <p>If I run the command <code>Add-Migration Initial -verbose</code>, I get this message:</p>
  <pre><code>Finding DbContext classes...
  Finding IDesignTimeDbContextFactory implementations...
  Finding application service provider...
  Finding Microsoft.Extensions.Hosting service provider...
  No static method 'CreateHostBuilder(string[])' was found on class 'Program'.
  No application service provider was found.
  Finding DbContext classes in the project...
  Found DbContext 'AppDataContext'.
  Microsoft.EntityFrameworkCore.Design.OperationException: Unable to create an object of type 'AppDataContext'. For the different patterns supported at design time, see https://go.microsoft.com/fwlink/?linkid=851728
   ---&gt; System.MissingMethodException: No parameterless constructor defined for type 'ProdTool.Models.AppDataContext'.
     at System.RuntimeType.CreateInstanceDefaultCtorSlow(Boolean publicOnly, Boolean wrapExceptions, Boolean fillCache)
     at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, Boolean wrapExceptions)
     at System.Activator.CreateInstance(Type type, Boolean nonPublic, Boolean wrapExceptions)
     at System.Activator.CreateInstance(Type type)
     at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.&lt;&gt;c__DisplayClass13_3.&lt;FindContextTypes&gt;b__13()
     --- End of inner exception stack trace ---
     at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.&lt;&gt;c__DisplayClass13_3.&lt;FindContextTypes&gt;b__13()
     at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.CreateContext(Func`1 factory)
     at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.CreateContext(String contextType)
     at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.AddMigration(String name, String outputDir, String contextType)
     at Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigrationImpl(String name, String outputDir, String contextType)
     at Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigration.&lt;&gt;c__DisplayClass0_0.&lt;.ctor&gt;b__0()
     at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.&lt;&gt;c__DisplayClass3_0`1.&lt;Execute&gt;b__0()
     at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
  Unable to create an object of type 'AppDataContext'. For the different patterns supported at design time, see https://go.microsoft.com/fwlink/?linkid=851728
  </code></pre>
  <p>As this is my first app in WPF with EF Core 3.1, I can't figure out, what the problem is.</p>
  <p>Thank you.</p>