A perfect example of wrongly identified and translated OBDII DTC by a Generic code reader! This code is cross-references to BMW DTC 238 (P1342,P1343), Misfire cyl.#1 with fuel cut-off - during warm up. It sounds different now, than the description of the generic P0313, right? I guess your car wasn't run low on fuel, was it? This code could set when the counted misfire reached the threshold at the initial start, usually within the first 3000 revolution. Misfire is measured by crankshaft speed fluctuation. Anyway, a common cause is carbon built-up on the valves, which at cold cranking could absorb a big chunk of the vaporized fuel - just like a sponge, therefor the fuel mixture will be very lean, causing misfire at least during a warm-up. You can even feel the misfire, the engine runs unevenly, which smooth out after warming up. I'd get the fuel pressure checked - just in case, and perform a professional combustion chamber / valve cleaning. This could be done by the use of a special solvent and equipment. Of course it could be caused by foamed up fuel (air bubbles in the fuel system) due to very low fuel in the gas tank, but this is the most common problem. You need to find a good BMW specialty shop with the right equipments, including OE diagnostic computer to identify the problem correctly. Generic scanners will cause confusion - especially for someone who isn't familiar with the car - and you can spend a lot for unnecessary repairs.
P0313 indicates that the computer detected a misfire with low fuel. I think the car was running out of gas. If you want to find a specialist, here's a directory link for you: https://repairpal.com/directory?address=98003&car_brand_names=BMW