Johann Sebastian Bach came by his reputation as the master of counterpoint and fugue with the 48 Preludes and Fugues of The Well Tempered Clavier, but counterpoint was his life's blood, and appeared in one form or another in most of his compositions. When Bach died in 1750, there was already a movement underfoot to change the tools of musical expression from counterpoint to a simpler form of melody and accompaniment. The result was that Bach was considered old fashioned, even when he was still alive, for some composers. But the genius of Bach knew no limits. He well understood the new trends in music, and could write in the new style as he chose.
The six sonatas for violin and keyboard were written when Bach was in service as the Kappelmeister at Köthen. Prince Leopold was a keen music lover whose court was Calvinist with simple church services that didn't use much in the way of music. Bach was there from 1717-1723, and wrote mostly secular pieces. It was here that he composed the Brandenburg Concertos, orchestral suites, pieces for solo violin and solo cello, and many other pieces.
The new style is blended with the old with the violin sonatas as they are written in the Baroque sonata de chiesa form of four movements with the tempo plan of slow-fast-slow-fast. But Bach makes the instruments partners, as both hands are written out for the keyboard player instead of just a figured bass line for the keyboardist to interpret.
These sonatas were not published until the early 19th century, but they were circulated by hand-made copies, and the music loving government official and patron of the arts Baron Gottfried van Swieten had copies of many of Bach's compositions in his music library. His weekly salon of performances of Bach's music helped musicians and music lovers become acquainted with Bach's music and lead to the revival of Bach's reputation in the 19th century.
I. Adagio - The first movement begins with the keyboard playing solo before the violin enters:
II. Allegro - The second movement begins with a fugal subject stated by the violin with an accompaniment:
III. Andante - The violin and right hand of the keyboard play in counterpoint in D major as the left hand maintains the bass:
IV. Allegro - The final movement, like most of the fast movements in the sonatas, has the violin and right hand play in counterpoint: