2

I'm trying to use Scaffold-DbContext but I got error:

Scaffold-DbContext 'Data Source=serverName;Initial Catalog=Test Trusted_Connection=True' Microsoft.EntityFrameworkCore.SqlServer

Connection string in another app:

"ConnectionStrings": { "AppConnection": "Server=serverName;database=Test;Trusted_Connection=True;MultipleActiveResultSets=true"

Error (scaffolding):

Login failed for user ''.

I dont have user in db and I connect by the same connectionstring to this base in another application and it works but not anymore with Scaffold-DbContext.

I tried to use: https://blog.sqlauthority.com/2009/05/21/sql-server-fix-error-provider-named-pipes-provider-error-40-could-not-open-a-connection-to-sql-server-microsoft-sql-server-error/

A connection was successfully established with the server, but then an error occurred during the login process. (Error Number: 233) https://entityframeworkcore.com/knowledge-base/49451319/dotnet-ef-scaffold-login-fails-for-user-sa-on-a-sqlserver-macos-linux

TylerH
  • 20,799
  • 66
  • 75
  • 101
Xia
  • 159
  • 10

1 Answers1

1

I guess that because you haven't explicitly specified Windows Authentication then it tries to use Username and Password which are null.

Add Integrated Security=SSPI to your connection string that uses Windows Authentication explicitly.

If it didn't work, feedback me to provide another solution.

A Farmanbar
  • 4,381
  • 5
  • 24
  • 42