Aldwin
Aldwin

Reputation: 23

Error when add property in ApplicationUser Identity

i am trying to use Identity, I want customize the class ApplicationUser by adding property for exemple "CustomeName" but when i try to register i have an error "SQL Exception : Invalid column name"

I've look on my DB and the column is not create in AspNetUsers so i think i've forgot something.

What i've do its :

In ApplicationUser.cs

    public class ApplicationUser : IdentityUser
    {
       public string CustomeName {get; set;}
    }

In RegisterViewModel.cs

    [Required]
    [Display(Name = "CustomeName")]
    public string CustomeName{ get; set; }

And in the AccountController.cs, in the method Register

var user = new ApplicationUser { UserName = model.Email, Email = model.Email, CustomeName = model.CustomeName }

I've make all migration.

What i've forgot ?

Thanks

Upvotes: 0

Views: 83

Answers (1)

Aldwin
Aldwin

Reputation: 23

Finaly resolved, I dont know if its my fault but in my migration i've never find the "AddColumn" so i've create a migration who delete the property, comment the delete into migration file, then add again my property and apply again my migration and that works :) thanks @MohsenEsmailpour, for put me on the good way

Upvotes: 1

Related Questions