I'm trying to use my own Users table for simplememership, adding some data to it. based on the sample here - http://blog.osbornm.com/2010/07/21/using-simplemembership-with-asp.net-webpages/ I've created a table with this model:
[Table("MyUsers")]
public class MyUsers
[Key]
[DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
public int UserId { get; set; }
public string UserName { get; set; }
public string Email { get; set; }
public string Gender { get; set; }
public DateTime DOB { get; set; }
I'm initializing it :
WebSecurity.InitializeDatabaseConnection("MyConnection", "MyUsers", "UserId", "UserName", autoCreateTables: true);
and on registration I call:
WebSecurity.CreateUserAndAccount(model.UserName, model.Password, new MyUsers {DOB = DateTime.Now.AddYears(-31),Email = "[email protected]",Gender = "Male",UserName = model.UserName});
But - I get this error: Cannot insert explicit value for identity column in table 'MyUsers' when IDENTITY_INSERT is set to OFF.
not sure how to set this off in VS2010, but I'm not sure why I even get this error, ans what should I fix.
Help appreciated, I'm trying to test if i can move a legacy asp.net project to MVC.
Thansk