简体   繁体   English

SQL Server连接到ASP.NET Core网站

[英]SQL server connection to ASP.NET Core website

I making a ASP.NET CORE 2.1 website. 我制作了一个ASP.NET CORE 2.1网站。 The database in Visual studio works fine, but when i deployed to the IIS which on another computer, the database not work. Visual Studio中的数据库工作正常,但是当我将IIS部署到另一台计算机上的IIS时,数据库无法正常工作。 In log, the error: 在日志中,错误:

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'.
.................

The connectionstring in the web.config: web.config中的连接字符串:

 "ConnectionStrings": {
"DefaultConnection": "Server=.\\SQLEXPRESS;Database=XXXX;Trusted_Connection=True;ID=XXXXXXX;pwd=XXXXXXXXX;MultipleActiveResultSets=true "

}, },

I read lot of articles for this, but i cant add any plus tags for the connection string, wil be error, the connection string is bad? 我为此阅读了很多文章,但是我无法为连接字符串添加任何加号,这会出错,连接字符串不好吗? When i run the project the in Visual Studio i can use database and i see the database in the SQL Server Managment Studio. 当我运行项目时,可以在Visual Studio中使用数据库,并且可以在SQL Server Managment Studio中看到该数据库。

For the database i use the "stock database" when created a the project in visual studio. 对于数据库,我在Visual Studio中创建项目时使用“股票数据库”。 Because i use Entity Framework i need another format connection string? 因为我使用实体框架,所以我需要另一个格式连接字符串? Stock Databse 股票数据库

Oh my jesus... I figured out the answer.. Just one f*... word... In connenction strig DONT USE database , the correct word is Initial Catalog and maybe use user id instead of id. 哦,我的耶稣...我想出了答案..只是一个f * ...单词...在connenstrig DONT USE database中 ,正确的单词是Initial Catalog ,也许使用用户ID而不是ID。 Correct string: 正确的字符串:

    "DefaultConnection": "Server=.\\SQLEXPRESS;Initial Catalog=XXX;Trusted_Connection=False;user id=XXX;pwd=XXX;MultipleActiveResultSets=true "

Based on my research if the server have morethan one databases .net core suffers to identify if the dabtase is mentioned in connection string. 根据我的研究,如果服务器具有多个数据库,.net核心将难以识别连接字符串中是否提到了dadaase。

This is not a problem if you use .Net framework, instead of .Net Core. 如果您使用.Net框架而不是.Net Core,这不是问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM