We know that our user in asp.net identity is the class with name of ApplicationUser
I would like to create other classes that inherit from it
Because?
Why, let's say I have the Client, Vendor, User class.
I want them all to be users of my system
So I have my default class that comes with creating the project:
public class ApplicationUser : IdentityUser
{
}
And I have my client class for example.
public class Cliente: ApplicationUser
{
public string CNPJ { get; set; }
}
When going to the Register action, I passed the Client to register as user, since it inherits from ApplicationUser:
public async Task<ActionResult> Register(Cliente model)
{
if (ModelState.IsValid)
{
var user = new ApplicationUser() {
UserName = model.UserName,
};
var result = await UserManager.CreateAsync(user, model.PasswordHash);
if (result.Succeeded)
{
await SignInAsync(user, isPersistent: false);
return RedirectToAction("Index", "Home");
}
else
{
AddErrors(result);
}
}
return View(model);
}
When going to this Action, I encounter the following error:
Invalid column name 'CNPJ'.
When trying to call method CreateAsync(user,model.PasswordHash)
What am I doing wrong? Can I do what I'm doing? Inherit and have multiple classes as "user" in identity?
PS: I've done migrations and gave update-database