  Gas flows play a fundamental role in galaxy formation and evolution,
providing the fuel for the star formation process. These mechanisms leave an
imprint in the amount of heavy elements. Thus, the analysis of this metallicity
signature provides additional constraint on the galaxy formation scenario. We
aim to discriminate between four different galaxy formation models based on two
accretion scenarios and two different star formation recipes. We address the
impact of a bimodal accretion scenario and a strongly regulated star formation
recipe. We present a new extension of the eGalICS model, which allows us to
track the metal enrichment process. Our new chemodynamical model is applicable
for situations ranging from metal-free primordial accretion to very enriched
interstellar gas contents. We use this new tool to predict the metallicity
evolution of both the stellar populations and gas phase. We also address the
evolution of the gas metallicity with the star formation rate (SFR). We then
focus on a sub-sample of Milky Way-like galaxies. We compare both the cosmic
stellar mass assembly and the metal enrichment process of such galaxies with
observations and detailed chemical evolution models. Our models, based on a
strong star formation regulation, allow us to reproduce well the stellar mass
to gas-phase metallicity relation observed in the local universe. However, we
observe a systematic shift towards high masses. Our $Mstar-Zg-SFR relation is
in good agreement with recent measurements: our best model predicts a clear
dependence with the SFR. Both SFR and metal enrichment histories of our Milky
Way-like galaxies are consistent with observational measurements and detailed
chemical evolution models. We finally show that Milky Way progenitors start
their evolution below the observed main sequence and progressively reach this
observed relation at z = 0.
