Fixes #80: "Entity NoneType does not belong to database" when using to_dict
Merge branch 'master' to 'orm': bugfix