Database: fixed lastInsertId in Context