The underlying provider failed to open , login failed for user IIS APPPOOL

10,158

The user under which the web application pool (associated to your web application) is running doesn't have permissions to access your database. You need to grant it permissions or run under another user who has permissions. So, to summarize: check under which user your application pool is running, then check that that user has access to your database.

Share:
10,158

Related videos on Youtube

Nadeem Khedr
Author by

Nadeem Khedr

I am a programmer who loves web development & consider it both a job & a hobby. Most of my background is .NET but for sometime now I have transitioned to the dynamic realm of programming (loving Javascript/Node/Ruby) Most of my work nowadays is making SPA apps. Worked mainly with Ember, Angular, Ionic, Backbone, Knockout & Firebase In my free time I play around with vim, bash, zsh & trying to find new tips/tricks to make myself more productive I blog & tweet often about new interesting technologies or problems that I find.

Updated on June 04, 2022

Comments

  • Nadeem Khedr
    Nadeem Khedr almost 2 years

    i am not a sql server guy but i am working on a client's application and want to connect to the database through EF Code first

    the Exception message that i have is

    The underlying provider failed to open

    The Exception details

    Cannot open database [DatabaseName] requested by the login. the login failed

    login failed for user 'IIS APPPOOL\ASP.NET v4.0"

    My web config

    <add name="TraininGoDB"
        providerName="System.Data.SqlClient"
        connectionString="Server=LOCALPCNAME\SQLEXPRESS;Database=[DATABASENAME];Integrated Security=True;"/>
    

    The EF context and entities are defined in a separate project with the app config of the following

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <configSections>
        <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
        <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.3.1.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
      </configSections>
      <entityFramework>
        <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework">
          <parameters>
            <parameter value="Data Source=(localdb)\v11.0; Integrated Security=True; MultipleActiveResultSets=True" />
          </parameters>
        </defaultConnectionFactory>
      </entityFramework>
    </configuration>
    

    i am using SQL Server Express 2008

    don't know the problem from the database configration or from the web config