Why's Delete not supported in ASP.Net Identity

asp.net, asp.net-identity, asp.net-mvc-5, visual-studio-2013

Solution

Delete User account

In 1.0, if you had to delete a User, you could not do it through the UserManager. They have now fixed it with 2.0:

var result = await UserManager.DeleteAsync(user);

See http://blogs.msdn.com/b/webdev/archive/2014/03/20/test-announcing-rtm-of-asp-net-identity-2-0-0.aspx

Problem

I was tinkering with the new auth features that recently RTM'd with Visual Studio 2013. While implementing a custom UserStore, I was having a look at the decompiled sources for the UserStore that ships in the box, `Microsoft.AspNet.Identity.EntityFramework.UserStore<TUser>`. I noticed that the method for deleting a user was not supported: ``` public class UserStore<TUser> : IUserLoginStore<TUser>, IUserClaimStore<TUser>, IUserRoleStore<TUser>, IUserPasswordStore<TUser>, IUserSecurityStampStore<TUser>, IUserStore<TUser>, IDisposable where TUser : IdentityUser { // other stuff omitted public virtual Task DeleteAsync(TUser user) { throw new NotSupportedException(); } } ``` That's strange isn't it? Why is deleting a user not supported? I admit I can't remember a production system that I've written that hard deleted user records, but I don't understand why this functionality is not supported. Is there a technical reason or is it simply because Microsoft feels that deleting user records is "bad" and leaves it as an exercise for the developer to override the method? Update In an attempt to understand what the ASP.NET team was thinking, I searched for framework usages of `DeleteAsync(TUser user)`. Nothing in the framework seems to invoke it. So, it seems that they could have completely left the member off of the `IUserStore<TUser>` interface. My conclusion at this point is that it's there to implement if you want and how you want and that it will only ever be invoked by your application code or future user management libraries.

Original source