As you already discovered, C # code to use $ addToSet:
var filter = Builders<Student>.Filter.Eq(s => s.StudentId, studentId);
var update = Builders<Student>.Update.AddToSet(s => s.CoursesList, courseId);
var result = await collection.UpdateOneAsync(filter, update);
However, $ addToSet will not work if the CourseList member was saved in the collection as null. The server requires that the existing value for $ addToSet be an array (this may be an empty array).
The easiest solution is to just keep an empty list for CoursesList instead of null when there are no courses.