Login failed for user 'NT AUTHORITY\NETWORK SERVICE'

后端 未结 9 1368
北海茫月
北海茫月 2020-11-29 04:23

I been strugling with this for 2 days now without comming any closer to solution. I have read 20-30 threads alteast and stil can not resolve this.

Please help me out

相关标签:
9条回答
  • 2020-11-29 05:19

    Make sure that the database is created. I got the same error when I applied the migration to the wrong project in the solution. When I applied the migration to the right project, it created the database and that solved the error.

    0 讨论(0)
  • 2020-11-29 05:21

    I am using Entity Framework to repupulate my database, and the users gets overridden each time I generate my database.

    Now I run this each time I load a new DBContext:

    cnt.Database.ExecuteSqlCommand("EXEC sp_addrolemember 'db_owner', 'NT AUTHORITY\\NETWORK SERVICE'");
    
    0 讨论(0)
  • 2020-11-29 05:23

    I was experiencing a similar error message that I noticed in the Windows Event Viewer that read:

    Login failed for user 'NT AUTHORITY\NETWORK SERVICE'. Reason: Failed to open the explicitly specified database. [CLIENT: local machine]

    The solution that resolved my problem was:

    1. Login to SqlExpress via SQL Server Management Studio
    2. Go to the "Security" directory of the database
    3. Right-click the Users directory
    4. Select "New User..."
    5. Add 'NT AUTHORITY\NETWORK SERVICE' as a new user
    6. In the Data Role Membership area, select db_owner
    7. Click OK

    Here's a screenshot of the above: Screenshot of adding new user Network Service as db_owner to SqlExpress

    0 讨论(0)
提交回复
热议问题