It is shown that the transition from L-mode to H-mode regimes in tokamaks can be reproduced using a two-fluid, fully electromagnetic, plasma model when a suitable particle sink is added at the edge. Such a model is implemented in the CUTIE code [A. Thyagaraja et al. , Eur. J. Mech. B/Fluids 23 , 475 (2004)] and is illustrated on plasma parameters that mimic those in the COMPASS-D tokamak with electron cyclotron resonance heating [Fielding et al. , Plasma Phys. Contr. Fusion 42 , A191 (2000)]. In particular, it is shown that holding the heating power, current, and magnetic field constant and increasing the fuelling rate to raise the plasma density leads spontaneously to the formation of an edge transport barrier ETB which occurs going from low to higher density experimentally. In the following quiescent period in which the stored energy of the plasma rises linearly with time, a dynamical transition occurs in the simulation with the appearance of features resembling strong edge localized modes. The simulation qualitatively reproduces many features observed in the experiment. Its relative robustness suggests that some, at least of the observed characteristics of ETBs and L-H transitions, can be captured in the global electromagnetic turbulence model.