title: Error "Unable to create an object of type 'ApplicationDbContext'."
body: <p>I'm working with Npgsql and Entity Framework. I'm trying to make new one migration but I have the error from the question title. I already have tried example from <a href="https://docs.microsoft.com/en-us/ef/core/miscellaneous/cli/dbcontext-creation#from-application-services" rel="nofollow noreferrer">MS documentation</a>.   </p>
  
  <p>So, my code is: </p>
  
  <pre><code>public class Program
  {
      public static void Main(string[] args)
          =&gt; CreateHostBuilder(args).Build().Run();
  
      // EF Core uses this method at design time to access the DbContext
      public static IHostBuilder CreateHostBuilder(string[] args)
          =&gt; Host.CreateDefaultBuilder(args)
              .ConfigureWebHostDefaults(
                  webBuilder =&gt; webBuilder.UseStartup&lt;Startup&gt;());
  }
  
  public class Startup
  {
      public Startup(IConfiguration configuration)
      {
          Configuration = configuration;
      }
      public IConfiguration Configuration { get; }
  
      public void ConfigureServices(IServiceCollection services)
      {
          services.AddDbContext&lt;ApplicationDbContext&gt;(options =&gt;
              options.UseNpgsql(Configuration.GetConnectionString("LalalaDb")));
      }
  }
  </code></pre>
  
  <p>Where is the problem? How I can make a migration? </p>
  
  <h3>Update</h3>
  
  <p>This is my <code>ApplicationDbContext.cs</code>: </p>
  
  <pre><code>public class ApplicationDbContext : IdentityDbContext
  {
      private readonly string _connectionString;
  
      public DbSet&lt;Customer&gt; Customers { get; set; }
      // and more DbSets are here ... 
  
      public ApplicationDbContext(IConfiguration configuration)
      {
          _connectionString = configuration.GetConnectionString("LalalaDb");
      }
  
      protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
      {
          optionsBuilder.UseNpgsql(_connectionString, b =&gt; b.MigrationsAssembly("EntityFrameworkProject"));
      }
  
      protected override void OnModelCreating(ModelBuilder modelBuilder)
      {
          base.OnModelCreating(modelBuilder);
      }
  }
  </code></pre>