title: Entity Framework responding very late at first request
body: <p>My WebAPI code is hosted on a GoDaddy server.</p>
  
  <p><strong>I have 2 issues:</strong></p>
  
  <blockquote>
    <ol>
    <li><p>The action method returns a response after 35 seconds for the first call after the code is updated on the server. From this issue, I am
    assuming that the application pool recycles and then it takes time,
    but I'm not sure.</p></li>
    <li><p>The same amount of time is being taken when a user sends a request to the server the second day. I am not sure why each request takes a
    lot of time. The application pool is not recycled in this case.</p></li>
    </ol>
  </blockquote>
  
  <p><strong>Class library project name: BusinessEntites</strong></p>
  
  <pre><code>public class BE_User
  {
      [Key]
      public Int64 UserID { get; set; }
      public String UserName { get; set; }
      public String Password { get; set; }
  }
  </code></pre>
  
  <p><strong>Class library project name: IDAL</strong></p>
  
  <pre><code>public interface IAccount
  {
      Task&lt;KeyValuePair&lt;String, BE_User&gt;&gt; GetUserLoginDetails(BE_User userDetails);
  }
  </code></pre>
  
  <p><strong>Class library project name: DatabaseDesign</strong></p>
  
  <pre><code>internal class UserMap : EntityTypeConfiguration&lt;BE_User&gt;
  {
      public UserMap()
      {
          HasKey(x =&gt; x.UserID);
          Property(x =&gt; x.UserName).IsRequired();
          Property(x =&gt; x.Password).IsRequired().HasMaxLength(100);
          ToTable("tblUser");
      }
  }
  </code></pre>
  
  <p><strong>Class library project name: DatabaseDesign</strong></p>
  
  <pre><code>public class ModelGeneration : DbContext
  {
      public ModelGeneration()
          : base("ConnectionString")
      {
          if (System.Configuration.ConfigurationManager.AppSettings["UpdateDatabase"] ==
             Convert.ToInt16(UpdateDatabase.Yes).ToString())
          {
              Database.SetInitializer(
                  new MigrateDatabaseToLatestVersion&lt;
                      ModelGeneration, DatabaseDesign.Migrations.Configuration&gt;());
          }
      }
  
      protected override void OnModelCreating(DbModelBuilder modelBuilder)
      {
          var typesToRegister = Assembly
              .GetExecutingAssembly()
              .GetTypes()
              .Where(type =&gt; !String.IsNullOrEmpty(type.Namespace))
              .Where(type =&gt; type.BaseType != null &amp;&amp; type.BaseType.IsGenericType
                 &amp;&amp; type.BaseType.GetGenericTypeDefinition() == 
                      typeof(EntityTypeConfiguration&lt;&gt;));
  
          foreach (var type in typesToRegister)
          {
              dynamic configurationInstance = Activator.CreateInstance(type);
              modelBuilder.Configurations.Add(configurationInstance);
          }
      }
      public virtual IDbSet&lt;BE_User&gt; tblUser { get; set; }
  }
  </code></pre>
  
  <p><strong>Class library project name: DatabaseDesign</strong></p>
  
  <pre><code>internal sealed class Configuration 
                : DbMigrationsConfiguration&lt;DatabaseDesign.ModelGeneration&gt;
  {
      public Configuration()
      {
          if (System.Configuration.ConfigurationManager.AppSettings["UpdateDatabase"] == 
                          Convert.ToInt16(UpdateDatabase.Yes).ToString())
          {
              AutomaticMigrationsEnabled = true;
          }
      }
  
      private void User(DatabaseDesign.ModelGeneration context)
      {
          BE_User SuperAdminUser = new BE_User
          {
              UserName = "Administrator",
              Password = "Some encrypted Password",
          };
          context.tblUser.Add(SuperAdminUser);
      }
  
      protected override void Seed(DatabaseDesign.ModelGeneration context)
      {
          User(context);
          context.SaveChanges();
      }
  }
  </code></pre>
  
  <p><strong>Class library project name: DAL</strong></p>
  
  <pre><code>public class Dal_Account : IAccount
  {
      public async Task&lt;KeyValuePair&lt;String, BE_User&gt;&gt; GetUserLoginDetails(
                                                                       BE_User userDetails)
      {
          try
          {
              using (var userContext = new ModelGeneration())
              {
                  userContext.Configuration.ProxyCreationEnabled = false;
                  var data = await userContext.tblUser
                      .FirstOrDefaultAsync(i =&gt; i.UserName == userDetails.UserName &amp;&amp; 
                                  i.Password == userDetails.Password);
                  if (data == null)
                      return new KeyValuePair&lt;string, BE_User&gt;("User not found", null);
                  return new KeyValuePair&lt;String, BE_User&gt;("", data);
              }
          }
          catch (Exception ex)
          {
              return new KeyValuePair&lt;String, BE_User&gt;(ex.Message, null);
          }
      }
  }
  </code></pre>
  
  <p><strong>WebAPI Project</strong></p>
  
  <pre><code>[Route("api/v1/GetUserLoginDetails"), HttpPost]
  public async Task&lt;IHttpActionResult&gt; GetUserLoginDetails(BE_User userDetails)
  {
      var result = await _account.GetUserLoginDetails(userDetails);
      return Ok(new { ErrorMessage = result.Key, result = result.Value });
  }
  </code></pre>
  
  <p>Do I need any code improvements or do any settings need to be modified?</p>