title: Query Azure SQL DB (VM) in LUIS Bot
body: <p>I have a BotFramework Project I built through azure with an integrated LUIS API for Language Processing, within my BasicLuisDialog.cs file I want to add a call to action for one of the LuisIntents to be a SQL DB Query, which takes the text the user entered into the bot, query that name against the SQL DB, then return the details about that person. </p>
  
  <p>I've currently added this in the BasicLuisDialog.cs under the intent I want it to query from:</p>
  
  <pre><code> [LuisIntent("Who_is_Employee")]
      public async Task Who_is_EmployeeIntent(IDialogContext context, LuisResult result)
      {
          EntityRecommendation recommendation;
          if(result.TryFindEntity("employee_name", out recommendation))
          {
              string role = EmployeeService.FindEmployee(recommendation.Entity);
              await context.PostAsync(" " + role);
          }
  </code></pre>
  
  <p>I created an EmployeeService.cs</p>
  
  <pre><code>using LuisBot.Model;
  using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  
  namespace LuisBot.Service
  {
      public class EmployeeService
      {
          public static string FindEmployee(string name)
          {
              string title = null;
              using(EmployeeDb db = new EmployeeDb())
              {
                 var rec = db.vw_Everyone.Where(c =&gt; c.givenName ==     name).FirstOrDefault();
              title = rec.title;
  
          }
  
          return title;
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>I created an EmployeeDb.cs: </p>
  
  <pre><code>namespace LuisBot.Model
  {
  using System;
  using System.Data.Entity;
  using System.ComponentModel.DataAnnotations.Schema;
  using System.Linq;
  
  public partial class EmployeeDb : DbContext
  {
      public EmployeeDb()
          : base("name=EmployeeDb")
      {
      }
  
      public virtual DbSet&lt;vw_Everyone&gt; vw_Everyone { get; set; }
  
      protected override void OnModelCreating(DbModelBuilder modelBuilder)
      {
      }
  }
  }
  </code></pre>
  
  <p>And the SQL View, called vw.Everyone.cs: </p>
  
  <pre><code>namespace LuisBot.Model
  {
  using System;
  using System.Collections.Generic;
  using System.ComponentModel.DataAnnotations;
  using System.ComponentModel.DataAnnotations.Schema;
  using System.Data.Entity.Spatial;
  
  public partial class vw_Everyone
  {
      [StringLength(256)]
      public string mail { get; set; }
  
      [StringLength(256)]
      public string SN { get; set; }
  
      [StringLength(256)]
      public string givenName { get; set; }
  
      [StringLength(256)]
      public string mobile { get; set; }
  
      [StringLength(256)]
      public string telephoneNumber { get; set; }
  
      [StringLength(256)]
      public string title { get; set; }
  
      [StringLength(256)]
      public string department { get; set; }
  
      [StringLength(256)]
      public string sectors { get; set; }
  
      [StringLength(256)]
      public string region { get; set; }
  
      [StringLength(256)]
      public string physicalDeliveryOfficeName { get; set; }
  
      [StringLength(256)]
      public string company { get; set; }
  
      public int? userAccountControl { get; set; }
  
      [StringLength(4000)]
      public string sAMAccountName { get; set; }
  
      [StringLength(256)]
      public string ADsPath { get; set; }
  
      [StringLength(513)]
      public string CN { get; set; }
  
      [StringLength(4)]
      public string ipPhone { get; set; }
  
      [Key]
      [DatabaseGenerated(DatabaseGeneratedOption.None)]
      public int Location { get; set; }
      }
  }
  </code></pre>
  
  <p>(Sorry if my code is a bit unformatted, I'm new to programming and StackFlow)</p>
  
  <p>This code I thought would work, but doesn't query the SQL DB and return me the info I want, I must be doing something wrong just can't figure out what. </p>