  In calculating hadronic contributions to precision observables for tests of
the Standard Model in lattice QCD, the electromagnetic current plays a central
role. Using a Wilson action with O($a$) improvement in QCD with
$N_{\mathrm{f}}$ flavors, a counterterm must be added to the vector current in
order for its on-shell matrix elements to be O($a$) improved. In addition, the
local vector current, which has support on one lattice site, must be
renormalized. At O($a$), the breaking of the SU($N_{\mathrm{f}}$) symmetry by
the quark mass matrix leads to a mixing between the local currents of different
quark flavors. We present a non-perturbative calculation of all the required
improvement and renormalization constants needed for the local and the
conserved electromagnetic current in QCD with $N_{\mathrm{f}}=2+1$
O($a$)-improved Wilson fermions and tree-level Symanzik improved gauge action,
with the exception of one coefficient, which we show to be order $g_0^6$ in
lattice perturbation theory. The method is based on the vector and axial Ward
identities imposed at finite lattice spacing and in the chiral limit. We make
use of lattice ensembles generated as part of the Coordinated Lattice
Simulations (CLS) initiative.
