【发布时间】:2019-07-28 01:47:39
【问题描述】:
我正在制作一个 ASP.NET CORE 2.1 网站。 Visual Studio 中的数据库工作正常,但是当我部署到另一台计算机上的 IIS 时,数据库无法正常工作。 在日志中,错误:
fail: Microsoft.EntityFrameworkCore.Query[10100]
An exception occurred in the database while iterating the results of a query for context type 'WebApplication3.Data.ApplicationDbContext'.
System.ArgumentException: Keyword not supported: 'id'.
.................
web.config 中的连接字符串:
"ConnectionStrings": {
"DefaultConnection": "Server=.\\SQLEXPRESS;Database=XXXX;Trusted_Connection=True;ID=XXXXXXX;pwd=XXXXXXXXX;MultipleActiveResultSets=true "
},
我为此阅读了很多文章,但我无法为连接字符串添加任何加号标签,会出错,连接字符串是坏的吗? 当我在 Visual Studio 中运行项目时,我可以使用数据库,并且我在 SQL Server Managment Studio 中看到了数据库。
对于数据库,我在 Visual Studio 中创建项目时使用“库存数据库”。 因为我使用实体框架我需要另一个格式连接字符串? Stock Databse
【问题讨论】:
-
Trusted_Connection=True;ID=XXXXXXX;pwd=XXXXXXXXX;没有意义。如果您使用的是受信任的连接,则不传递用户名和密码(相反,如果您不使用受信任的连接,则传递值)。 -
很高兴知道,但如果使用 Trusted_Connection with true, no password 或 Trusted_connection false with userid, and password, no connect to database, 错误消息:
An exception occurred in the database while iterating the results of a query for context type 'WebApplication3.Data.ApplicationDbContext'. System.Data.SqlClient.SqlException (0x80131904): Cannot open database "XXX" requested by the login. The login failed. Login failed for user 'IIS APPPOOL\XXXv11'. -
听起来用户/登录
IIS APPPOOL\XXXv11没有访问数据库的权限,@bobo。您需要检查您的 SQL Server 上的用户/登录权限,并为其提供相关/正确的权限(我们不知道这些是什么,我们对您的系统一无所知,或者它做了什么)。 -
@Lamu ,感谢登录问题的答案。我添加了权限并且登录问题消失了,现在我只得到与问题相同的错误。
标签: c# asp.net sql-server database-connection connection-string