'ASP.NET Core Web API - Cannot implicitly convert type 'System.Threading.Tasks.Task<Merchant?>' to 'Merchant'

In my ASP.NET Core-6 Web API, I am implementing Repository pattern. I have this code:

Model:

public class Merchant
{
    public Guid Id { get; set; }

    [Required]
    [Column(TypeName = "Varchar")]
    [StringLength(100)]
    public string MerchantName { get; set; }

    [Required]
    [Column(TypeName = "Varchar")]
    [StringLength(50)]
    public string AccountNumber { get; set; }
    public NotificationRequired? NotificationRequired { get; set; }
    public string NotificationUrl { get; set; }
}

Interface:

public interface IAdminMerchantRepository : IGenericRepository<Merchant>
{
    Merchant GetMerchantById(Guid id);
}

public class AdminMerchantRepository : GenericRepository<Merchant>, IAdminMerchantRepository
{
    private readonly ApplicationDbContext _dbContext;
    private readonly DbSet<Merchant> _adminMerchants;
    public AdminMerchantRepository(ApplicationDbContext dbContext) : base(dbContext)
    {
        _dbContext = dbContext;
        _adminMerchants = _dbContext.Set<Merchant>();
    }
    public Merchant GetMerchantById(Guid id)
    {
        var merchant = _dbContext.Merchants.Include(e => e.User)
                                            .FirstOrDefaultAsync(e => e.Id == id);
        return merchant;
    }
}

I got this strange error:

Cannot implicitly convert type 'System.Threading.Tasks.Task<Merchant?>' to 'Merchant'

It highlights merchant in return merchant

I never used any Task.

Where is it getting the error from, and how do I resolve it?

Thank you.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source