Custom application user.

Vote:
 

Hello There,

I have followed all the steps given into the https://world.episerver.com/documentation/developer-guides/CMS/security/episerver-aspnetidentity/.

So I have created as class


public class CustomUser : ApplicationUser
{
public virtual string FirstName { get; set; }
}

So after build and run the site. I was expecting that, the column "FirstName" would be  get generate into table AspNetUsers table in database. But its not working.

Any help.

#217957
Mar 03, 2020 7:22
Vote:
 

Hi Dipak,

When you say that you have followed all the steps - did you switch all ApplicationUser usages on startup.cs (or whatever file you have your OWIN StartUp) to your CustomUser?

This is easy for you to test on your local machine:

  • create new Alloy MVC site (with or without search)
  • create your custom application user class
  • modify the startup.cs and replace all usages of 'ApplicationUser' with your custom app user type
  • run Alloy
    • you create the initial user
  • look at the table 'AspNetUsers' and you can see that your custom property / properties are here

Was the site first created using Episervers ApplicationUser and then you decided to switch to your own custom implementation? If yes, then that is why you don't see any changes in your AspNetUsers table. You need to run migrations and it isn't straight forward like just running enable-migrations and pointing to Episerver ASP.NET identity type and assembly (like you would normally run migrations in an ASP.NET EF project).

So if you can start clean with the user database, that is your fastest option or see this blog post about running the migrations programmatically. I'm not sure if that will either work as you are changing the actual user type too.

#218217
Mar 08, 2020 9:17
- Mar 09, 2020 5:44
Hello Antti,

You are correct, site first created using EpiServer ApplicationUser and then I decided to switch to my own custom implementation.
Thank you for your observation. Let me try to migration solution.

Dipak Salve.
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.