title: Why does Entity Framework with Windows Authentication not pass my credentials to SQL Server?
body: <p>I'm trying to get an MVC 4 intranet site with Entity Framework 5 working on web server running IIS6 but Windows Authentication/Integrated Security is not working right because the error says</p>
  
  <blockquote>
    <p><strong>Stack Trace:</strong> </p>
    
    <p>[SqlException (0x80131904): Login failed for user
    'EASTDOMAIN\WEBDEV2$'.]<br>
    System.Data.SqlClient.SqlInternalConnection.OnError(SqlException
    exception, Boolean breakConnection) +5104926<br>
    System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() +260<br>
    System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior,
    SqlCommand cmdHandler, SqlDataReader dataStream,
    BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject
    stateObj) +2294<br>
    System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean
    enlistOK) +35<br>
    System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo
    serverInfo, String newPassword, Boolean ignoreSniOpenTimeout,
    TimeoutTimer timeout, SqlConnection owningObject, Boolean
    withFailover) +250<br>
    System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo
    serverInfo, String newPassword, Boolean redirectedUserInstance,
    SqlConnection owningObject, SqlConnectionString connectionOptions,
    TimeoutTimer timeout) +932<br>
    System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection
    owningObject, TimeoutTimer timeout, SqlConnectionString
    connectionOptions, String newPassword, Boolean redirectedUserInstance)
    +195    System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity
    identity, SqlConnectionString connectionOptions, Object providerInfo,
    String newPassword, SqlConnection owningObject, Boolean
    redirectedUserInstance) +316<br>
    System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions
    options, Object poolGroupProviderInfo, DbConnectionPool pool,
    DbConnection owningConnection) +185<br>
    System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection
    owningConnection, DbConnectionPool pool, DbConnectionOptions options)
    +33    System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection
    owningObject) +524<br>
    System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection
    owningObject) +66<br>
    System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection
    owningObject) +479<br>
    System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection
    owningConnection) +108<br>
    System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection
    outerConnection, DbConnectionFactory connectionFactory) +126<br>
    System.Data.SqlClient.SqlConnection.Open() +125<br>
    System.Data.SqlClient.SqlProviderServices.UsingConnection(SqlConnection
    sqlConnection, Action<code>1 act) +85<br>
    System.Data.SqlClient.SqlProviderServices.UsingMasterConnection(SqlConnection
    sqlConnection, Action</code>1 act) +341<br>
    System.Data.SqlClient.SqlProviderServices.GetDbProviderManifestToken(DbConnection
    connection) +258<br>
    System.Data.Common.DbProviderServices.GetProviderManifestToken(DbConnection
    connection) +34</p>
    
    <p>[ProviderIncompatibleException: The provider did not return a
    ProviderManifestToken string.]<br>
    System.Data.Common.DbProviderServices.GetProviderManifestToken(DbConnection
    connection) +163<br>
    System.Data.Entity.ModelConfiguration.Utilities.DbProviderServicesExtensions.GetProviderManifestTokenChecked(DbProviderServices
    providerServices, DbConnection connection) +41</p>
    
    <p>[ProviderIncompatibleException: An error occurred while getting
    provider information from the database. This can be caused by Entity
    Framework using an incorrect connection string. Check the inner
    exceptions for details and ensure that the connection string is
    correct.]<br>
    System.Data.Entity.ModelConfiguration.Utilities.DbProviderServicesExtensions.GetProviderManifestTokenChecked(DbProviderServices
    providerServices, DbConnection connection) +166<br>
    System.Data.Entity.ModelConfiguration.Utilities.DbConnectionExtensions.GetProviderInfo(DbConnection
    connection, DbProviderManifest&amp; providerManifest) +40<br>
    System.Data.Entity.DbModelBuilder.Build(DbConnection
    providerConnection) +46<br>
    System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext
    internalContext) +62<br>
    System.Data.Entity.Internal.RetryLazy<code>2.GetValue(TInput input) +117<br>
    System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
    +453    System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type
    entityType) +18<br>
    System.Data.Entity.Internal.Linq.InternalSet</code>1.Initialize() +56<br>
    System.Data.Entity.Internal.Linq.InternalSet<code>1.Include(String path)
    +18    System.Data.Entity.Infrastructure.DbQuery</code>1.Include(String path) +73    System.Data.Entity.DbExtensions.Include(IQueryable<code>1
    source, String path) +85<br>
    System.Data.Entity.DbExtensions.Include(IQueryable</code>1 source,
    Expression<code>1 path) +126<br>
    Reclosing.Controllers.RecloserController.Index() +198<br>
    lambda_method(Closure , ControllerBase , Object[] ) +62<br>
    System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase
    controller, Object[] parameters) +17<br>
    System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext
    controllerContext, IDictionary</code>2 parameters) +188<br>
    System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext
    controllerContext, ActionDescriptor actionDescriptor, IDictionary<code>2
    parameters) +27<br>
    System.Web.Mvc.Async.&lt;&gt;c__DisplayClass42.&lt;BeginInvokeSynchronousActionMethod&gt;b__41()
    +28    System.Web.Mvc.Async.&lt;&gt;c__DisplayClass8</code>1.b__7(IAsyncResult
    <em>) +12    System.Web.Mvc.Async.WrappedAsyncResult<code>1.End() +50    System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult
    asyncResult) +29<br>
    System.Web.Mvc.Async.&lt;&gt;c__DisplayClass39.&lt;BeginInvokeActionMethodWithFilters&gt;b__33()
    +59    System.Web.Mvc.Async.&lt;&gt;c__DisplayClass4f.&lt;InvokeActionMethodFilterAsynchronously&gt;b__49()
    +240    System.Web.Mvc.Async.&lt;&gt;c__DisplayClass37.&lt;BeginInvokeActionMethodWithFilters&gt;b__36(IAsyncResult asyncResult) +12    System.Web.Mvc.Async.WrappedAsyncResult</code>1.End()
    +50    System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult
    asyncResult) +31<br>
    System.Web.Mvc.Async.&lt;>c</em>_DisplayClass2a.b_<em>20()
    +23    System.Web.Mvc.Async.&lt;>c</em>_DisplayClass25.b_<em>22(IAsyncResult
    asyncResult) +128    System.Web.Mvc.Async.WrappedAsyncResult<code>1.End()
    +50    System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult
    asyncResult) +26<br>
    System.Web.Mvc.&lt;&gt;c__DisplayClass1d.&lt;BeginExecuteCore&gt;b__18(IAsyncResult
    asyncResult) +14<br>
    System.Web.Mvc.Async.&lt;&gt;c__DisplayClass4.&lt;MakeVoidDelegate&gt;b__3(IAsyncResult
    ar) +25    System.Web.Mvc.Async.WrappedAsyncResult</code>1.End() +55<br>
    System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +41
    System.Web.Mvc.Async.&lt;>c</em>_DisplayClass4.b__3(IAsyncResult
    ar) +25    System.Web.Mvc.Async.WrappedAsyncResult<code>1.End() +55<br>
    System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +28<br>
    System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult
    asyncResult) +10<br>
    System.Web.Mvc.&lt;&gt;c__DisplayClass8.&lt;BeginProcessRequest&gt;b__3(IAsyncResult
    asyncResult) +28<br>
    System.Web.Mvc.Async.&lt;&gt;c__DisplayClass4.&lt;MakeVoidDelegate&gt;b__3(IAsyncResult
    ar) +25    System.Web.Mvc.Async.WrappedAsyncResult</code>1.End() +55<br>
    System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)
    +30    System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult
    result) +9<br>
    System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
    +9042429    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously) +184</p>
    
    <p>-------------------------------------------------------------------------------- Version Information: Microsoft .NET Framework Version:4.0.30319;
    ASP.NET Version:4.0.30319.1016</p>
  </blockquote>
  
  <p><strong>Here is my web.config:</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;!--
      For more information on how to configure your ASP.NET application, please visit
      http://go.microsoft.com/fwlink/?LinkId=169433
      --&gt;
  &lt;configuration&gt;
      &lt;configSections&gt;
          &lt;!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --&gt;
          &lt;section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /&gt;
      &lt;/configSections&gt;
      &lt;connectionStrings&gt;
               &lt;add name="ReclosingContext" connectionString="Data Source=sqlserverbox\devtest;Initial Catalog=Reclosing;Integrated Security=SSPI;MultipleActiveResultSets=True" providerName="System.Data.SqlClient" /&gt;
  
      &lt;/connectionStrings&gt;
      &lt;appSettings&gt;
          &lt;add key="webpages:Version" value="2.0.0.0" /&gt;
          &lt;add key="webpages:Enabled" value="false" /&gt;
          &lt;add key="PreserveLoginUrl" value="true" /&gt;
          &lt;add key="ClientValidationEnabled" value="true" /&gt;
          &lt;add key="UnobtrusiveJavaScriptEnabled" value="true" /&gt;
      &lt;/appSettings&gt;
      &lt;system.web&gt;
          &lt;compilation targetFramework="4.0" /&gt;
          &lt;authentication mode="Windows" /&gt;
          &lt;authorization&gt;
              &lt;deny users="?" /&gt;
          &lt;/authorization&gt;
          &lt;pages&gt;
              &lt;namespaces&gt;
                  &lt;add namespace="System.Web.Helpers" /&gt;
                  &lt;add namespace="System.Web.Mvc" /&gt;
                  &lt;add namespace="System.Web.Mvc.Ajax" /&gt;
                  &lt;add namespace="System.Web.Mvc.Html" /&gt;
                  &lt;add namespace="System.Web.Optimization" /&gt;
                  &lt;add namespace="System.Web.Routing" /&gt;
                  &lt;add namespace="System.Web.WebPages" /&gt;
              &lt;/namespaces&gt;
          &lt;/pages&gt;
      &lt;/system.web&gt;
      &lt;system.webServer&gt;
          &lt;validation validateIntegratedModeConfiguration="false" /&gt;
          &lt;modules runAllManagedModulesForAllRequests="true" /&gt;
      &lt;handlers&gt;
              &lt;remove name="cshtml-ISAPI-4.0_64bit" /&gt;
              &lt;remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" /&gt;
              &lt;remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" /&gt;
              &lt;remove name="ExtensionlessUrlHandler-Integrated-4.0" /&gt;
              &lt;add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" /&gt;
              &lt;add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" /&gt;
              &lt;add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" /&gt;
                          &lt;add name="cshtml-ISAPI-4.0_64bit" path="*.cshtml, *." verb="GET,HEAD,POST,DEBUG" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="Script" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" /&gt;
          &lt;/handlers&gt;
                  &lt;defaultDocument&gt;
                          &lt;files&gt;
                                  &lt;add value="index.aspx" /&gt;
                          &lt;/files&gt;
                  &lt;/defaultDocument&gt;&lt;/system.webServer&gt;
      &lt;runtime&gt;
          &lt;assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"&gt;
              &lt;dependentAssembly&gt;
                  &lt;assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" /&gt;
                  &lt;bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" /&gt;
              &lt;/dependentAssembly&gt;
              &lt;dependentAssembly&gt;
                  &lt;assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" /&gt;
                  &lt;bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.0.0.0" /&gt;
              &lt;/dependentAssembly&gt;
              &lt;dependentAssembly&gt;
                  &lt;assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" /&gt;
                  &lt;bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" /&gt;
              &lt;/dependentAssembly&gt;
              &lt;dependentAssembly&gt;
                  &lt;assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" /&gt;
                  &lt;bindingRedirect oldVersion="1.0.0.0-1.3.0.0" newVersion="1.3.0.0" /&gt;
              &lt;/dependentAssembly&gt;
          &lt;/assemblyBinding&gt;
      &lt;/runtime&gt;
      &lt;entityFramework&gt;
          &lt;defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" /&gt;
      &lt;/entityFramework&gt;
          &lt;location path="Web.config"&gt;
                  &lt;system.web&gt;
                          &lt;compilation defaultLanguage="c#" /&gt;
                  &lt;/system.web&gt;
          &lt;/location&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p><strong>'EASTDOMAIN\WEBDEV2$' is not my UserID, but is the domain\servername.</strong> 
  I've tried playing around with adding an impersonate to the config to no avail. This worked fine in IIS Express on my local PC connecting to the same SQL 2005 DB (which is on its own box). My local PC runs Windows 7 using VS2012.</p>
  
  <p>I'm new to this so if anyone can help, I could really use it! I'm getting tired of beating my head against the wall!</p>