I started a project with asp.net MVC internet aplication... I made some changes to the default code... I created my own user context:
public class UsersDBContext : DbContext
{
public DbSet<UserProfile> UserProfiles { get; set; }
And I made some changes to the AccountModel:
[Table("UserProfile")]
public class UserProfile
{
[Key]
[DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
public int UserId { get; set; }
public string UserName { get; set; }
public int? test { get; set; }
}
I added this column test. As you can see , this column is nullable..... But in runtime I get this error when I try to register an user:
Cannot insert the value NULL into column 'test'.column does not allow nulls. INSERT fails.
The error happens in this line:
WebSecurity.CreateUserAndAccount(model.UserName, model.Password);
Does anyone know any solution?
EDIT: Migration Code:
public override void Up()
{
AlterColumn("dbo.UserProfile", "test", c => c.Int());
}
public override void Down()
{
AlterColumn("dbo.UserProfile", "test", c => c.Int(nullable: false));
}