26 September 2018

Solving Error 500 (internal server error) when running a newly deployed ASP.NET Core WebAPI

I encountered an Error 500 when I first run the ASP.NET Core 2.1 Web API deployed on a Windows 2008 Server machine with IIS version 7.5.

When I checked the log (since I set stdoutLogEnabled="true"), I found an error that says:

fail: Microsoft.EntityFrameworkCore.Database.Command[20102]
      Failed executing DbCommand (2ms) [Parameters=[], CommandType='Text', CommandTimeout='60']
      CREATE DATABASE [SampleDb];
System.Data.SqlClient.SqlException (0x80131904): CREATE DATABASE permission denied in database 'master'.

I know it has something to do with the permission in the database.

The solutions below just worked for me:

  1. Connect to the database using SQL Server Management Studio.
  2. Click Security, then Logins
  3. Double click the user that will access your database. In my case it is NT AUTHORITY\NETWORK SERVICE
  4. Select the Server Roles and check the dbcreator, public, and sysadmin credentials.

No comments:

Post a Comment