Sorted out persisting records to the database