Two-dimensional covalent organic frameworks (2D-COFs) exhibit high activity in the electrochemical nitrogen reduction reaction (NRR), while the structure-performance relationship toward which remains an unsolved problem, therefore hindering the development of efficient catalysts. In this work, a total of 145 candidate transition metal phthalocyanine (TMPc-DX) materials comprised of 29 transition metals and X-phthalocyanine (X = N, O, F, S, and Cl) are evaluated for their capabilities in the NRR by density functional theory calculations. Our computations showed that metal atoms in TMPc-DN/DF/DCl materials could efficiently activate N2 molecules by doping with electron-withdrawing groups. The catalysts MoPc-DN and NbPc-DN are recognized to exhibit the highest electrocatalytic performance for the NRR with the lowest limit potentials of 0.31 and 0.32 V, respectively. Moreover, NbPc-DN showed a significant advantage by suppressing the hydrogen evolution reaction, making it a top contender among TMPc-DX materials for the electrocatalytic NRR. Through detailed orbital interaction analysis, our research has demonstrated that embedding transition metals into the substrate (Pc-DX) results in a direct correlation between the number of electrons transferred to the substrate and the reduction of energy splitting of the metal's d orbital, which directly causes a decrease in the metal's magnetic moment. Consequently, the affinity of the metal for N2 adsorption is directly proportional to the extent of the electron transfer. Our findings underscore the significance of the material's magnetic moment as a preliminary indicator for gauging the effectiveness of N2 adsorption.