This may not help, but why not use dependency injection to end up with a method more like the following, and I'd make it an async method (note: I have not checked this against intellisense or anything):
public async Task<Account?> GetAccountAsync(Guid? userID)
{
try
{
if (userId == null || userId == Guid.Empty)
throw new ArgumentNullException("userId should not be null.");
using BtDbContext context = _dbContextFactory.CreateDbContext();
Account? account = await context.Accounts.SingleOrDefaultAsync(c => c.UserId.Equals(userID));
return account;
}
catch (ArgumentNullException ex)
{
_errReport.LogErr(ex);
}
catch (Exception ex)
{
_errReport.LogErr(ex);
}
return null;
}
This is assuming _dbContextFactory and _errReport are private readonly variables and defined in the constructor through dependency injection.