If someone is stuck because of the same issue. Make sure you have properly linked the database (as you might have copied the code directly from some example).
Just update the name of the database in managedObjectModel and persistentStoreCoordinator methods in AppDelegate.