Correlated electron systems, particularly iron-based superconductors, are extremely sensitive to strain, which inevitably occurs in the crystal growth process. Built-in strain of this type has been proposed as a possible explanation for experiments where nematic order has been observed at high temperatures corresponding to the nominally tetragonal phase of iron-based superconductors. Strain is assumed to produce linear defect structures, e.g. dislocations, which are quite similar to O vacancy chainlets in the underdoped cuprate superconductor YBCO. Here we investigate a simple microscopic model of dislocations in the presence of electronic correlations, which create defect states that can drive magnetic anisotropy of this kind, if spin orbit interaction is present. We estimate the contribution of these dislocations to magnetic anisotropy as detected by current torque magnetometry experiments in both cuprates and Fe-based systems.