Saves an enity into the database using insert or update as required. Requires a keyfield that exists on both the entity and the database.