The Sonata in E flat major for flute or recorder, BWV 1031 (also H. 545) is a work in three movements, usually attributed to Johann Sebastian Bach, although some question his authorship of the piece and hold his son Carl Philipp Emmanuel as the true composer. The work was written around 1730 and it was published only a hundred and thirty years later, in 1860.