Electrocatalytic coupling of CO and N2 to synthesize urea under ambient conditions is considered a promising strategy to replace traditional industrial technology. It is crucial to find efficient electrocatalysts that can adsorb and activate N2 and promote the C-N coupling reaction. Herein, a new two-dimensional porous carbon nitride material with multiactive sites is designed, in which boron and transition metal are embedded. Through a series of screening, B2Cr2, B2Mn2, and B2Os2 are predicted to be potential electrocatalysts for urea synthesis. Mechanistic studies are performed on bidentate metal-metal and metal-boron sites, and both NCON and CO mechanisms are explored. The electronic structure analysis shows that there is a strong N2 chemical adsorption within the bidentate site and that the N≡N bond is significantly activated. A new mechanism where free CO is inserted for C-N coupling within the two-dimensional porous structure is proposed.