They are different. B31.1 is a Code pertaining to Power Piping, while ASME B&PV Code, Section VIII is applicable to unfired pressure vessels. You really need to review the Scope for Section VIII and B31.1.
The fabricator which holds a U Certificate of Authorization from the ASME may perform nonboiler external piping fabrication to B31.1. It may not perform ASME B31.1 boiler external pipe welding fabrication.
There are many differences between VIII-1 & B31.1:
-B31.1 is closer to B31.3 than VIII-1, as befits the component being designed and fabricated.
-Calculation equations are different (such as shells)
-Material allowable stresses are a bit different.
-Inspection requirements differ