0

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

4
  • 3
    Trusted_Connection=True;ID=XXXXXXX;pwd=XXXXXXXXX; doesn't make sense. If you are using a trusted connection you don't pass the username and password (and conversely if you aren't using a trusted connection you do pass the values). Commented Mar 6, 2019 at 11:46
  • Good to know, but if use Trusted_Connection with true, no password or Trusted_connection false with userid, and password, no connect to databse, the error message: 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'. Commented Mar 6, 2019 at 11:55
  • 2
    Sounds like the user/login IIS APPPOOL\XXXv11 doesn't have access to the database then, @bobo. You need to check the user/login's permissions on your SQL Server and provide it with the relevant/correct permissions (we don't know what those are, we know nothing about your system, or what it does). Commented Mar 6, 2019 at 11:59
  • @Lamu ,Thanks the answer for login issue.I added the permission and login issue is gone, now i got only the same error as in the question. Commented Mar 6, 2019 at 12:20

2 Answers 2

3

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 "
Sign up to request clarification or add additional context in comments.

Comments

0

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.

1 Comment

Fortunately, you can mix the things.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.