Ugh. The ability to earn miles on some of these flights is a significant reason for me leaving UA and joining Miles and More last year (that and the generous mileage for BD flights

). The following list comes from experience with UA's programme (if UA gives the miles I assume BD will too).
The easy one is Cityline (usually flight numbers commencing LH5***). CL is a division of LH, much like BD regional (without the flights to NOC) so you will always get miles on BD for these.
The other easy one are flights operated by LH Regional partners with an LH number in the 9000-9999 range - I have never got these credited to any programme other than LH (and it can be a struggle even then!).
Eurowings is more complex, but I've got miles into my UA account on internal German flights (in the LH2000-2999 range) and on a variety of short haul international flights to and from DUS (with a variety of flight numbers in the 1000, 2000, 3000 and 5000 ranges). I've had problems with a couple of EW flights in the LH6000-6999 range.
Augsburg, Cirrus, Contact et al are more problematic, though it does sometimes work. Officially the line from UA is that these carriers do not accrue mileage. Generally where the LH flight number is in the same sort of numeric range as mainline LH flights serving the same region, the miles seem to credit. Goes without saying that the LH flight number must be booked.
This may all be changing (for the better, one hopes), with the formation of LH Regional, which will, with any luck, result in uniform crediting of all LH Regional flights. They so after all brand themselves as LH flights, wear LH uniforms, serve tea out of yellow and blue plastic beakers...