Bobo
Bobo

Reputation: 43

SQL server connection to ASP.NET Core website

I making a ASP.NET CORE 2.1 website. The database in Visual studio works fine, but when i deployed to the IIS which on another computer, the database not work. 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:

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

For the database i use the "stock database" when created a the project in visual studio. Because i use Entity Framework i need another format connection string? Stock Databse

Upvotes: 0

Views: 5304

Answers (2)

Bharath
Bharath

Reputation: 123

Based on my research if the server have morethan one databases .net core suffers to identify if the dabtase is mentioned in connection string.

This is not a problem if you use .Net framework, instead of .Net Core.

Upvotes: 0

Bobo
Bobo

Reputation: 43

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. Correct string:

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

Upvotes: 3

Related Questions