Change the entity id type from int to long.

This allows us to drop in future the free list and meta data tables.
Don't reuse entity ids.

Reasoning:
- The entity ids are now of type long and should thus not reoccur.
- It allows for further simplifications.
 -> It is no longer necessary to manage external references.
    As they where mainly needed to check if the refrences
    of a restored entity are still valid and thus have not been reused yet.
Don't maintain and restore external references.

This code simplification is possible, as ids do no longer get reused.
Merge PR #1411 by @flo - entity id refactoring