SimpleMembership is designed to put the user information in these two tables, which have a one-to-zero-or-one relationship. The UserProfile table has a unique UserId and a UserName, and UserProfile can be customized by the developer. This UserId is a foreign key for the webpages_Membership table, which contains the password and other security information in it. The reason for keeping information in these table separate is that the data in webpages_Membership is not required if OAuth is being used. If OAuth is being used then the password and other security details will be on another system.
Now back to the problem. I found it hard to believe that using DeleteUser did not remove both tables because here is what the documentation says.
This method deletes the entry in the membership account table (by default, webpages_Membership). If deleteAllRelatedData is true, all user data that is stored in the user table is also deleted.
So here is the quick and dirty test I ran.
I stepped through with the debugger after the CreateUserAndAccount and saw an entry for the user in both tables. Then I stepped over DeleteUser and checked the database again. The entry in UserProfile was gone but the one inwebpages_Membership was still there. This was a far cry from what the documentation described as the behavior for this method and verified what the person asking the question in StackOverflow observed.
So I thought I would try something else to see if I could come up with a workaround for this issue. Here is the code I tried.
Now when I stepped through with the debugger when I hit DeleteAccount the entry from webpages_Membershipwas removed and then when I hit DeleteUser the entry in UserProfile was removed. Now we do not have any orphans hanging around. Not sure if and when Microsoft will fix this bug but at least there is a workaround.
I should also point out that if you have a user mapped to roles using DeleteUser will throw a foreign key exception. You have to remove any mapped roles before you can use it.