I don't know what exactly caused my problem, but I've found a solution myself.
Somehow IIS APPPOOL\DefaultAppPool
doesn't even need any additional permissions for the database server, it can connect to it even if its name is not included in the database's Logins
section. Simply, the database it creates is somehow very tightly coupled with the IIS APPPOOL\DefaultAppPool
entity (whatever it actually is) AND, if you delete the database that belongs to IIS APPPOOL\DefaultAppPool
or any other pool and then try to create a new database with the same application pool, it acts as if the database wasn't actually deleted previously, but as if you were trying to access what's remaining from it with an account that didn't created it. Maybe it's not very easy to understand what I'm saying, but I think that the deletion of the database that belongs to an instance of an application pool not only deletes it, but also "unlinks" it from that pool and when you try to create a new database in the same application pool it just doesn't allow you, because you are "unlinked" from it, even if it doesn't even exist anymore. Maybe there still are some "links" in the database server, but they are not valid anymore, so the application pool is treated as something that tries to override the remainder of the database but doesn't have permissions to do it.
SO FINALLY THE FIX!!!
To fix this, just create a new application pool with a different name than the one that had previously created the database, move your application there and it'll work. I'm not sure if you can then create application pool with the same name and then create the database, but I guess yes. And, of course, restart IIS (I restart it through Internet Information Services (IIS) Manager
) after you create a new pool.
UPDATE!!!
Yes, I've just tested and now can confirm that you can create an application pool with the same name, but before this you have to delete it not only from IIS Manager's application pool's window but also from Users
directory of your computer (where users' files are stored, i.e. C:\Users) and then you can create a new pool with the same name.
It took me a long time to find out this strange behavior. I did it through lots of error and trial, so I'm happy to share it so that maybe someone one day will fix a similar problem faster than me.
Good luck guys!