8

I'm trying to enable login using the MVC 4 RC default template. I did it the same way as in MVC 3, Aspnet_regsql.exe -> SQL server. Then I made the connection string point to the SQL server.

When I try to register a new user I get this:

Server Error in '/' Application.

Invalid column name 'ApplicationId'.
Invalid column name 'UserName'.
Invalid column name 'ApplicationId'.
Invalid column name 'UserId'.
Invalid column name 'UserName'.
Invalid column name 'IsAnonymous'.
Invalid column name 'LastActivityDate'.

Error in AccountController:

              Line 85: // Attempt to register the user
              Line 86: MembershipCreateStatus createStatus;
Error here -> Line 87: Membership.CreateUser(model.UserName, model.Password, model.Email, passwordQuestion: null, passwordAnswer: null, isApproved: true, providerUserKey: null, status: out createStatus);
              Line 88:
              Line 89: if (createStatus == MembershipCreateStatus.Success)

I've been trying to google this error but no luck so far. Is there maybe some other way I should be doing this in MVC 4?

judehall
  • 884
  • 12
  • 27
  • Did you find a solution? If I run the SQL profiler, the SQL statements generated by the `DefaultMembershipProvider` use different table names than `aspnet_regsql` (`Applications` instead of `aspnet_Applications` and `Users` instead of `aspnet_Users`). One solution is to rename the tables to suit the membership provider or to write a custom membership provider for MVC. – dan radu Jul 31 '12 at 06:41

1 Answers1

10

I received the same error because I was using membership tables from aspnet_regsql.exe version 2.x. I ran the aspnet_regsql.exe executable in the version 2.x folder and uninstalled the tables. Then with the new universal providers you dont need to use the above executable anymore, the tables are created when you connect to the first time.

This article goes into more detail of the differences between the old aspnet_Memembership vs the Universal Providers.

Stronger Password Hasing Net

The key points from the article:

Firstly, there’s no more aspnet_regsql, you just make sure your connection string is set and the account has DBO rights (don’t worry, it doesn’t have to stay this way) then run the app up and attempt to perform any action which should cause the membership provider to hit the DB (i.e. log on – it doesn't matter that there isn't an account).

Thats it all there is to it.

Dan Beaulieu
  • 19,406
  • 19
  • 101
  • 135
Jake1164
  • 12,291
  • 6
  • 47
  • 64
  • "Firstly, there’s no more aspnet_regsql, you just make sure your connection string is set..." and everything worked perfectly:) No more regsql tool! Thank you very much:) – judehall Sep 12 '12 at 17:00
  • The problem I have with the fact that there is no aspnet_regsql.exe equivalent for the new System.Web.Providers framework, is that I cannot create the db schema and then seed the Membership with administrator users and roles PRIOR to allowing public users from registering. I built the MvcInstaller (NuGet and github) and it uses the aspnet_regsql.exe to install the Membership system for administrators. This doesn't allow me to update my component for the new system. It's frustrating. – Kahanu Sep 27 '12 at 18:26