Wednesday, 7 August 2013

Websecurity.CreateUserAndAccount on Azure doesn't work

Websecurity.CreateUserAndAccount on Azure doesn't work

I have a method that registers a new user using
WebSecurity.CreateUserAndAccount(model.UserName, model.Password) The
problem is that in the UserProfile model I have added a GUID Key. On my
local machine this just populates an empty Guid when I call this method.
On azure however, I get the following error:
System.Data.SqlClient.SqlException (0x80131904): Cannot insert the
value NULL into column 'Key', table 'Scheduler.dbo.UserProfile'; column
does not allow nulls. INSERT fails.
Now, I've tried to generate a new GUID in the constructor of the model,
manually have the Set{} generate a new GUID and I get the same error.
When I try to use the CreateUserAndAccount overload like:
WebSecurity.CreateUserAndAccount(model.UserName, model.Password, new {
Key = Guid.NewGuid() });
I get the following syntax error (run time):
Incorrect syntax near the keyword 'Key'.
I've spent a good part of the morning trying to figure this out and I just
can't. By the way all of the above methods still result in an empty GUID
00000000-0000-0000-0000-000000000000 and the overload gives me syntax
error on my local machine.

No comments:

Post a Comment