The Microsoft SQL Server exception Microsoft.Data.SqlClient.SqlException (0x80131904): The INSERT permission was denied on the object, database, schema ‘dbo’ is the permission-related issue we can able to predict based on the exception details. There are similar issues like this because this particular issue is related to INSERT permission, similarly, there can be issues related to SELECT permission, DELETE permission, UPDATE permission, EXECUTE permission, and Create Table permission.
When I try to host the application for the first time on the IIS server, I faced several problems running the application. One of the issues is Microsoft.Data.SqlClient.SqlException (0x80131904): The INSERT permission was denied on the object, database, schema ‘dbo’. My application had code to Insert and select data from the database. The application was failing and it was throwing the above exception.
If we analyze the issue, we can clearly understand that issue is related to permission. Right-click on your database to get the Database Properties window then navigate to the permission option, The user I am using is NT/AUTHORITY\LOCAL Service. So have to select the appropriate user and in the table, we can able to see a list of actions with a checkbox to select Grant for each action as shown image below.
I supposed to check the Select action and Insert action to solve my present issue, but I may use other actions also for database transactions. So I could give all-important permissions and solved the permission issue. Just need to check the required action type and hit ok as shown below image.
I got this error along with series of errors while hosting my ASP.NET Core web application on IIS hosting platform for the first time. I have shared other errors also with solution below.