title: System.Data.Entity.Core.EntityException occurred
body: <p>I am struggling to connect to DB. My db doesn't require any username and pwd.</p>
  
  <p>My connection string in Web.config is </p>
  
  <pre><code>&lt;connectionStrings&gt;
        &lt;add name="EmployeeContext" 
             connectionString="Data Source=LAPTOP-
  HKBMHNCA\SQL2016AGAIN;Initial Catalog=aspnet-CodeFirstWithMVC-
  20170821025529;Integrated Security=True;" 
             providerName="System.Data.SqlClient" /&gt;  
   &lt;/connectionStrings&gt;
  </code></pre>
  
  <p>The error log is as follows</p>
  
  <pre><code>  System.Data.Entity.Core.EntityException occurred
    HResult=0x80131501
    Message=The underlying provider failed on Open.
    Source=EntityFramework
    StackTrace:
     at System.Data.Entity.Core.EntityClient.EntityConnection.Open()
     at System.Data.Entity.Core.Objects.ObjectContext.EnsureConnection(Boolean 
     shouldMonitorTransactions)
     at System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T]
     (Func`1 func, IDbExecutionStrategy executionStrategy, Boolean 
     startLocalTransaction, Boolean releaseConnectionOnSuccess)
     at System.Data.Entity.Core.Objects.ObjectQuery`1.&lt;&gt;c__DisplayClass7.
     &lt;GetResults&gt;b__5()
     at 
     System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult]
     (Func`1 operation)
     at System.Data.Entity.Core.Objects.ObjectQuery`1.GetResults(Nullable`1 
     forMergeOption)
     at System.Data.Entity.Core.Objects.ObjectQuery`1.
     &lt;System.Collections.Generic.IEnumerable&lt;T&gt;.GetEnumerator&gt;b__0()
     at System.Data.Entity.Internal.LazyEnumerator`1.MoveNext()
     at MVCDemo.Controllers.EmployeeController.Details(Int32 id) in 
     C:\Users\homeuser\documents\visual studio 
     2017\Projects\MVCDemo\MVCDemo\Controllers\EmployeeController.cs:line 17
     at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext 
     controllerContext, IDictionary`2 parameters)
     at 
  System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext 
  controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 
  parameters)
  at System.Web.Mvc.Async.AsyncControllerActionInvoker.
  &lt;BeginInvokeSynchronousActionMethod&gt;b__39(IAsyncResult asyncResult, 
  </code></pre>
  
  <p>ActionInvocationinnerInvokeState)atSystem.Web.Mvc.Async.AsyncResultWrapper.Wrap
      pedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult)
     at </p>
  
  <p>System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncR
     esult asyncResult)
     at 
     System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.
     b__3d()
     at </p>
  
  <p>System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.&lt;>c__DisplayClass46.b__3f()</p>
  
  <p>Inner Exception 1:
  SqlException: Login failed for user 'IIS APPPOOL\DefaultAppPool'.</p>
  
  <p>My controller is </p>
  
  <pre><code>namespace MVCDemo.Controllers
  {
      public class EmployeeController : Controller
      {
      // GET: Employee
          public ActionResult Details(int id)
          {
              EmployeeContext employeeContext = new EmployeeContext();
  
              Employee employee =    employeeContext.Employees.Single(emp =&gt; emp.EmployeeId == id);
  
          return View(employee);
          }
      }
  }
  </code></pre>
  
  <p>My model class is </p>
  
  <pre><code>namespace MVCDemo.Models
  {
  public class Employee
  {
      public int EmployeeId { get; set; }
      public string Name { get; set; }
      public string Gender { get; set; }
      public string City { get; set; }
  
  
  
   }
  }
  
  namespace MVCDemo.Models
  {
      public class EmployeeContext:DbContext
      {
          public DbSet&lt;Employee&gt; Employees { get; set; }
  
      }
  }
  </code></pre>
  
  <p>Please advise me as I am new to this concept.</p>
  
  <p>Thanks in advance</p>
  
  <p>Regards
  Advit</p>