title: ASP.NET Core: Making service asynchronous
body: <p>I have an ASP.NET core application where I use a service layer between my controllers and Entity Framework. </p>
  
  <p>Currently my services are synchronous, but I would like to make them asynchronous. </p>
  
  <p>This is an controller example:</p>
  
  <pre><code>public async Task&lt;IActionResult&gt; Search(BusinessesSearchModel model)
  {
      var resultModel = await _businessService.Search(model);
      return Ok(resultModel);
  }
  </code></pre>
  
  <p>And this is an example of my service:</p>
  
  <pre><code>public interface IBusinessesService
  {
       Task&lt;BusinessResultListModel&gt; Search(BusinessesSearchModel model);
  }
  
  public class BusinessesService : IBusinessesService
  {
       public async Task&lt;BusinessResultListModel&gt; Search(BusinessesSearchModel model)
      {
          var queryResult = (from b in MyDBContext.Businesses
  
                              where b.Name.Contains(model.Name)
                              &amp;&amp; b.Phone.Contains(model.Phone)
  
                              select new BusinessesListModel
                              {
                                  ID = b.ID,
                                  Name = b.Name,
                                  Phone = b.Phone
                              }
                              ).ToList();
          var resultModel = new BusinessResultListModel();
          resultModel.data = queryResult;
          resultModel.othervalue = "other value";
          return resultModel;
      }
  }
  </code></pre>
  
  <p>This does not work. Visual Studio tells me:</p>
  
  <blockquote>
    <p>This async method lacks 'await' operators and will run synchronously</p>
  </blockquote>
  
  <p>Where should I add <code>await</code> to make this async?</p>