General Electric Co. agreed to sell a majority stake in a solar-energy business to BlackRock Inc., giving the investment giant footing in a growing market as the ailing manufacturer shifts its focus elsewhere.