First of all, I would like to recommend several articles found in these days:
1.Create an ASP. NET MVC app with Auth and SQL DB and deploy to Azure app Service
The knowledge I get from this article is primarily about how roles are added.
The first thing I learned was the role of the feature [authorize]: primarily restricting the role to access the method, such as adding the [Authorize (role= "admin")] attribute on index (), only the user of the Admin role can access it.
So I was thinking, if my own site requires three levels of user (myself, admin, normal user) How do I add these three characters?
I look for, finally found a feasible way, is to use the NuGet console to install a entityframework database update operation, as long as the console input enable-migration can be installed automatically, A migration folder appears in the project with a configuration CS file.
Then, you can do the same thing as the middle section of the article to implement the role of adding and user binding specific roles.
It's just a way of adding a role, and updating the database tables with these code is the entityframework of the code-first pattern.
2.Customizing profile information in ASP. NET Identity in VS. templates
This article let me know is that I change the identity generated by the user table, you can change the User table field, you do not have to find a way to configure a lot of account issues, I was thinking that I built an account management, but also think about, Anyway, MVC provides identity2.0, why do you have to build an account management, and do not necessarily safe, or first use the identity bar, until feel really unable to solve their own problems to find a way.
Actually adding the Identity User table field is very simple, just need to add an attribute in the ApplicationUser class in IdentityModel, and write the model is a meaning, Then use the migration (Migration Tool) to update the database is OK
Update-database
Identity add Management in ASP.NET5 MVC templates (Roles and user additions)