Moved all database logic from Extensions to McmRepository.