Metal-organic frameworks(MOFs) are important functional materials. MOF-5(IL)(Zn4O(BDC)3(BDC=1,4-benzenedicarboxylate) was in situ synthesized by the electrochemical method using a tunable ionic liquid(IL), 1-butyl-3-methylimidazolium chloride, as template. The crystallization of distinctly spherical MOF-5(IL) synthsized in ionic liquid by the electrochemical method is attributed to π-π stacking effect, ionic bond, and coordination bond. The analysis results show that the product MOF-5(IL) exhibits better crystallinity and higher thermal stability than MOF-5 generated using the solvothermal method. The cyclic voltammetry reveals that the electrosynthesis reaction is irreversible and controlled by the diffusion. The experiments on methylorange degradation show that the unique structure characteristics of MOF-5(IL) can enhance the photocatalytic ability of Bi OBr. Therefore, MOFs can replace noble metals to improve the photocatalytic properties of bismuth oxyhalide.