public class EcommerceContext : IdentityDbContext<IdentityUser>
{
    public EcommerceContext(DbContextOptions options) : base(options)
    {
    }
// use real database
        services.AddDbContext<EcommerceContext>(c =>
            c.UseSqlServer(Configuration.GetConnectionString("EcommerceConnection"),
                x => x.MigrationsAssembly("Ecommerce.Web")));
PM> add-migration InitializeDb Build started... Build succeeded. Unable to create an object of type 'EcommerceContext'. For the different patterns supported at design time, see https://go.microsoft.com/fwlink/?linkid=851728
                        
In my case the solution had multiple startup projects. Anit was fixed by defining only one startup project.