C# 将应用程序移动到IIS 7时,我收到EntityException
我使用EntityFramework4和SQLServer2008编写了一个带有asp.NETMVC的应用程序。 在localhost上一切正常,但当我移动到iis时,会出现以下异常:C# 将应用程序移动到IIS 7时,我收到EntityException,c#,asp.net,sql-server,entity-framework,entity-framework-4,C#,Asp.net,Sql Server,Entity Framework,Entity Framework 4,我使用EntityFramework4和SQLServer2008编写了一个带有asp.NETMVC的应用程序。 在localhost上一切正常,但当我移动到iis时,会出现以下异常: Cannot open database "Template" requested by the login. The login failed. Login failed for user 'IIS APPPOOL\DefaultAppPool'. 您可以更新连接字符串以显式使用有效用户名和密码登录SQL S
Cannot open database "Template" requested by the login. The login failed.
Login failed for user 'IIS APPPOOL\DefaultAppPool'.
您可以更新连接字符串以显式使用有效用户名和密码登录SQL Server,也可以更改DefaultAppPool进程在IIS中运行的标识。
对于第一个问题,您必须在SQL Server中创建一个登录名,并具有对目标数据库的足够访问权限。
对于第二个,您必须转到IIS=>Application Pools=>Default App Pool=>Set Properties=>Process Model=>Change Identity to LocalSystem或您的自定义登录