Look closely at your code:
.where(x => x.CourseName == coursename || EF.Functions.Like(x.CourseName, $"%(coursename.Trim()}%") && x.CourseCategory == categoryId)
Are you sure this bit is right:
$"%(coursename.Trim()}%"
^ ^
| |
That's not string interpolation, but this is:
$"%{coursename.Trim()}%"
^ ^
| |