的SQLException:无效的对象名称DBO&LT;表名&GT;使用本地系统身份时, [英] SqlException: Invalid object name dbo.<tablename> when using LocalSystem as Identity
问题描述
我部署了一个asp.net网页API在我的本地IIS(7.0),我不能访问数据库打通。
I deployed a asp.net web api on my local IIS (7.0) and I can't get through in accessing the database.
在身份(在过程模型)设置为本地系统
,API将返回此异常:
When the identity (under process model) is set to LocalSystem
, API will return this exception:
无效的对象名称dbo.tablename
Invalid object name 'dbo.tablename'
如果我设置的身份 ApplicationPoolIdentity
,该API将返回此异常:
If I set the identity to ApplicationPoolIdentity
, the API will return this exception:
无法打开数据库DBNAME的登录请求。登录失败。
用户登录失败'IIS APPPOOL \\ ASP.NET v4.0的。
Cannot open database "dbname" requested by the login. The login failed. Login failed for user 'IIS APPPOOL\ASP.NET v4.0'.
解决方案的尝试:
-
<一个href=\"http://stackoverflow.com/questions/7698286/login-failed-for-user-iis-apppool-asp-net-v4-0\">Login失败,用户IIS APPPOOL \\ ASP.NET v4.0的'
https://www.youtube.com/watch?v=18 -zatWd68s
添加权限,文件夹和.mdf文件为ASP.NET V4.0
Added permissions to both folder and .mdf file to 'ASP.NET v4.0'
<一个href=\"https://blogs.msdn.microsoft.com/sqlex$p$pss/2011/12/08/using-localdb-with-full-iis-part-2-instance-ownership/\" rel=\"nofollow\">https://blogs.msdn.microsoft.com/sqlex$p$pss/2011/12/08/using-localdb-with-full-iis-part-2-instance-ownership/
其他相关信息:
连接字符串(在的web.config
)
<add name="DbContext"
connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=[dbname];Trusted_Connection=Yes;"
providerName="System.Data.SqlClient" />
我也尝试使用运行使用IIS防爆preSS Visual Studio中的应用程序,它工作得很好。
I also tried running the application using Visual Studio using IIS Express, it worked fine.
推荐答案
您已经看到了<一个href=\"https://blogs.msdn.microsoft.com/sqlex$p$pss/2011/12/08/using-localdb-with-full-iis-part-2-instance-ownership/\" rel=\"nofollow\">https://blogs.msdn.microsoft.com/sqlex$p$pss/2011/12/08/using-localdb-with-full-iis-part-2-instance-ownership/
它说,你基本上有3个选项,
It says you basically have 3 options,
- 运行IIS作为ID(坏主意),
- 运行的LocalDB作为一个共享实例,或
- 使用SQL防爆preSS
后者可能是最好的建议。
The latter is probably the best advice.
这篇关于的SQLException:无效的对象名称DBO&LT;表名&GT;使用本地系统身份时,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!