'Rest Api not runing on IIS

I have an Rest Api created with .net 6, which has a database created with EF code -first and does the migration on database. I do publish to Folder and select to use my connection String and my Migration when doing the publish. I also installed Hosting Bundle, and verified that it is installed When i browse my site i get:

HTTP Error 500.30 - ASP.NET Core app failed to start

Edited:

In Event Viewer i get :

CREATE DATABASE permission denied in database 'master'.

The migration is in needs to be done in another database of course,and i have granted access to everyone user to my publish folder.

I also have a background task running in this app, and for this reason i initialise the migration before the app is running with this configuration in Program.cs:

 using (var scope = host.Services.CreateScope())
                {
                    var db = scope.ServiceProvider.GetRequiredService<DbContext>();
                    DbInitializer.Initialize(db);
                }

What am i doing wrong? In IISExpress in Visual Studio , the app runs, builds, does the migration.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source