This lick is composed from the B minor Blues scale but played all legato style and three notes per string style. I actually see the lick from the first position of the Blues scale which is B minor but I connect it with the B natural minor which shares notes with D major which is the key of the song so this way I can easily make my way to the lick I actually create the melodic side of the soloing from the B natural minor. The other thing which is really cool in this system is to combining the scales so in this case I generally play in B minor Aeolian scale but then I visualize how the Blues scale pertains to the Aeolian scale so I can weave in and out between those two scales

If you are used to playing the Major scale and see everything in comparison to the Major scale then you can also just kick the lick off when you reach the sixth position of the Major scale on the G string but you still have to add the F to the scale so the lick does not fit completely into the Major scale but it sounds killer. But what this system will also give you is a way to use a lick in multiple ways and in all key so I would like to encourage you to try it out in your own songs as well. Good Luck !