2

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) enter image description here

Then I gave them the necessary permissions :

enter image description here enter image description here

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

5
  • Does this answer useful to you ? Commented Jun 8, 2022 at 12:26
  • already try sadly.. i have created my login for nt authority Commented Jun 8, 2022 at 12:32
  • Can you show your connection string?pls hide sensitive info. Commented Jun 8, 2022 at 12:56
  • "COBRAContext": "Server=(localdb)\\mssqllocaldb;Database=COBRA_DB;Trusted_Connection=False;MultipleActiveResultSets=true;" (atm its local proto idk if its sensitive) Commented Jun 8, 2022 at 13:05
  • I have try to create another login "test" with pswd => its works on visual studio but not on the IIS server. I am confused Commented Jun 8, 2022 at 13:06

1 Answer 1

2

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;

enter image description here

Sign up to request clarification or add additional context in comments.

3 Comments

I understand, but how am I going to see the errors of my database without the development mode in this case? They are hidden if I understand correctly. However, thank you for your response and your time.
@JulesValignat Usually we create COBRA_DB_Development and COBRA_DB. COBRA_DB_Development can be used for team collaborative development. The previous one can only be tested on your own machine.
Thanks a lot for your experience. Have a nice day.

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.