I would argue for two broad categories of melody for solos. Let's call one generative and the other composed.
Generative works form recombining small melodic units, motifs, figures, to realize the harmonic background. A lot of jazz solos work that way (scale and broken chord bit, enclosures, etc.) In Dixieland jazz I think of it a textural filling in. The process lends itself to improvisation. To a certain degree the results are lines that a interchangeable, or at least can be similar. Jazz fans may object to me saying that, but on the other hand there are those who will think it all just sounds the same.
Composed style in less a method of recombination and aims for a much more uniquely identifiable line. It requires more careful refinement of the line to obtain the unique quality. This type does not lend itself to improvisation, because of the careful editing and refinement needed for a good line.
The distinction between the two approaches is not about good versus bad. It's just a style difference.
I have forever struggled when trying to improvise a metal solo over a backing track, like I would with blues or even rock.
I think when you're working with blues or blues derived rock styles, you're working in a style, along with jazz, that has a generative approach as part of the definition of the style.
Metal, along with certain other rock styles (guitarists like Neil Giraldo or Elliott Easton come to mind, so roughly New Wave), favor a more composed approach. In that style the solo becomes an especially important to the identity of the song.
Your struggle is probably about the fundamental difference between the styles. I don't mean to say 'don't do it' or 'it can't be done.' I'm only trying to explain what may be the source of the struggle. If you're trying generative, bluesy style, it may simply be incompatible, style-wise, with metal. Perhaps the generative palette needs to come from elements other than blues licks and pentatonic boxes, etc.