I've been stuck on this error for several days and I've already tried a lot of things. I am deploying my MVC C# application under .NET6 Entity FrameWork on my local machine. I rather succeeded and my application is available from my machine. However, whenever I try to access my DB, I get the following error:
SqlException: Cannot open database "COBRA_DB" requested by the login. The login failed.
Login failed for user 'AUTORITE NT\Système'.
I documented myself on NT Authority and I understood that it was necessary to add this profile for permissions. I open SQL Manager Studio, I add the following profiles: (French version but equivalent I suppose):
AUTORITE NT\SERVICE LOCAL
AUTORITE NT\Système
(NT AUTHORITY/LOCAL SERVICE | NT AUTHORITY/System)
Then I gave them the necessary permissions :
However it is still impossible for me to access my DB from my local server. Can you help me, I'm a bit lost. Thanks
CodePudding user response:
After you deploy your project, you could't use the connection string like (localdb)\\mssqllocaldb
. It just for development environment.
Usually we should connect the db like below. The format should be like :
Data Source=XXX.windows.net,1433;Initial Catalog=db;Persist Security Info=False;User ID=user;Password=mypassword;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;
Connection Timeout=30;