I have a web project (C# Asp.Net, EF 4, MS SQL 2008 and IIS 7) and I need to migrate it to IIS 7 locally (at the moment works fine with CASSINI).
Locally in IIS I ha
As pointed out, Do not use Windows Authentication, Use SQL Server Authentication
Also if you created connection using "Server Connection" dialog, make sure to check the connections in web.config. It is likely that you created/modified connection and it was stored as trusted connection in web.config. Simply use this authentication
<add name="MyDBConnectionString" connectionString="Data Source=localhost;Initial Catalog=Finantial;User ID=xxx;Password=xxx" providerName="System.Data.SqlClient"/>
which should fix the error.
I did exactly as @JeffOgata said but I got the error:
Windows NT user or group 'IIS APPPOOL\ASP.NET v4.0' not found. Check the name again. (Microsoft SQL Server, Error: 15401)
I looked at my error message again and it said Login failed for user 'IIS APPPOOL\DefaultAppPool'.
After adding a user named IIS APPPOOL\DefaultAppPool everything worked.
I Have the same problem I solved it by changing Integrated Security=True to false
now its working
For the record, if you encounter this error after switching from LocalDB to SQLEXPRESS, make sure the database already esists in SQLEXPRESS. You can verify this in Management Studio.
I had the same problem when using Entity Framework after switching to SQLEXPRESS from LocalDB. I had to run Update-Database command. I was able to successfully connect after that.
I had this message and I use Windows Authentication on the web server.
I wanted the currently authenticated web user to be authenticated against the database, rather than using the IIS APPPOOL\ASP.NET v4 User specified in the App Pool.
I found by entering the following in the web.config fixed this for me:
<system.web>
<identity impersonate="true" />
</system.web>
https://msdn.microsoft.com/en-us/library/bsz5788z.aspx
I see other Answers regarding creating the AppPool username in the SQL DB or just to use SQL Auth. Both would be correct if you didn't want to capture or secure individual Windows users inside SQL.
Tom
You can change the ApplicationPoolIdentity from IIS7 -> Application Pools -> Advanced Settings.

Under ApplicationPoolIdentity you will find local system. This will make your application run under NT AUTHORITY\SYSTEM, which is an existing login for the database by default.
Edit: Before applying this suggestion you should note and understand the security implications.