Using effective field theory, the effects of new particles or interactions can be captured in a model-independent way by supplementing the standard model Lagrangian with higher-dimensional operators. A measurement of the cross section for top quarks produced in association with a W or Z boson, using 19.5/fb of proton-proton collisions with a center-of-mass energy of 8 TeV, collected by the CMS experiment at the LHC, is extended within this framework to set constraints on the Wilson coefficients of five dimension-six operators. An additional measurement of the same processes using 35.9/fb of proton-proton collisions with a center-of-mass energy of 13 TeV collected by the CMS experiment is used to perform a more sophisticated study of eight dimension-six operators and present bounds on their Wilson coefficients.