The error occurred because I used an incorrect cast while trying to display enum values in a dropdown in the Razor view. Since Enum.GetValues can't be directly used as an array, it needed to be cast to DifficultyLevel with Cast(). The incorrect expression wasn't understood by Razor, resulting in an error.
In Edit.cshtml, I replaced the form in which I perform Enum operations with the following form:
<div class="form-group mb-4">
<label asp-for="Difficulty" class="form-label font-weight-bold">Zorluk Derecesi</label>
<select asp-for="Difficulty" class="form-control bg-secondary text-light border-0 shadow-sm">
<option value="">Seçiniz</option>
@foreach (var level in Enum.GetValues(typeof(Question.DifficultyLevel)).Cast<Question.DifficultyLevel>())
{
<option value="@level">@level</option>
}
</select>
<span asp-validation-for="Difficulty" class="text-danger"></span>
</div>