I am deploying a web application with asp.net core 2.1 using IIS, the process completed successfully and the site is working as it should except for the database (which is a localdb instance) I always get this error:
SqlException: Cannot open database "Mydb" requested by the login. The login failed. Login failed for user 'IIS APPPOOL\CORE'.
I already enabled loadUserProfile="true" and setProfileEnvironment="true"
in the applicationHost.config for the site pool
and using these links Link#1 - Link#2 I added the user 'IIS APPPOOL\CORE' with the right permissions to the database users and localdb with SSMS and using this Link I made sure all the SQL Server services are running and under the right port.
I also tried shared instances of localdb but didn't work either.
I saw some duplicates of this question but none of them worked for me.
I did manage to make it work under the local windows account the one I am logged in with, but I think it's not the right approach since it poses some security risks in case the site got hacked that's why virtual accounts are recommended for this use because they have limited access to system resources, so with this being said the connection string is fine and the problem should be with the virtual pool account not being able to access the database.
Is there something that I am missing?