ASP.NET MVC 4 SimpleMembershipProvider, WebMatrix WebSecurity CreateUserAndAccount Create New User SQL

----------------------
ASP.NET MVC 4 Membership Overview: http://aaron-hoffman.blogspot.com/2013/02/aspnet-mvc-4-membership-users-passwords.html
----------------------

Using SQL Profiler, below is the SQL that is executed when the ASP.NET MVC 4 SimpleMembershipProvider's WebMatrix.WebData.WebSecurity.CreateUserAndAccount() method is called:

Text below in bold is dynamic and represents the UserName and Password properties passed to the CreateUserAndAccount() method as well as the UserId generated as part of user creation.

Similarly, the name of the UserId and UserName columns, and the name of the UserProfile table may also be different based on your specific configuration.


exec sp_executesql N'SELECT [UserId] FROM [UserProfile] WHERE (UPPER([UserName]) = @0)',N'@0 nvarchar(23)',@0=N'UserName'

exec sp_executesql N'INSERT INTO [UserProfile] ([UserName]) VALUES (@0)',N'@0 nvarchar(23)',@0=N'UserName'

exec sp_executesql N'SELECT [UserId] FROM [UserProfile] WHERE (UPPER([UserName]) = @0)',N'@0 nvarchar(23)',@0=N'UserName'

exec sp_executesql N'SELECT COUNT(*) FROM [webpages_Membership] WHERE UserId = @0',N'@0 int',@0=UserId

exec sp_executesql N'INSERT INTO [webpages_Membership] (UserId, [Password], PasswordSalt, IsConfirmed, ConfirmationToken, CreateDate, PasswordChangedDate, PasswordFailuresSinceLastSuccess) VALUES (@0, @1, @2, @3, @4, @5, @5, @6)',N'@0 int,@1 nvarchar(68),@2 nvarchar(4000),@3 bit,@4 nvarchar(4000),@5 datetime,@6 int',@0=UserId,@1=N'PasswordHash',@2=N'',@3=1,@4=NULL,@5='2013-07-17 19:57:07.427',@6=0



Hope this helps,
Aaron

Comments

Popular posts from this blog

Search iPhone Text Messages with SQLite SQL Query

How to Turn Off Microsoft Arc Touch Mouse Scroll Sound Vibration

Configure SonarAnalyzer.CSharp with .editorconfig, no need for SonarCloud or SonarQube