Get the right Ecu, I believe it's a silver label for a non-VANOS M50, but, unlike everything I say, that's not gospel. Lol. But with the right ECU, DME and harness to fit the engine, it'll all bolt together fine. Think of the motor as one piece of the whole unit; the whole unit being:
ECU, motor, and harness -> all matching. Then it should be able to almost literally, plug right in.
1995 525iA 250k mi
2006 325i/6 57k mi
2003 350Z 88k mi