Apply commit 50b05dbb6eb467c83c942a1880235668b479d049 in core:

Adding check to make sure the association has a value. If not, then including associations during serialization will throw an exception if the foreign key is null