We’ll start with the empty web application so that we can describe all the steps in their simplest form, making this whole process easier to understand.
You can create a subclass of Identity User and add more properties.
Those will be present in the user’s table when we actually create the database.
NET Core named tag helpers we’ll enable them for all the views using another new feature which is a file name _View Imports.cshtml.
Create the _View Imports.cshtml file in the Views folder and add this inside: , which we did here so that all the views can use tag helpers. Create a folder named Home inside Views and inside it create a file named Index.cshtml.
I suspect that this is included just because in old membership systems the concept of Role was very prominent. What the cookie middleware does is it redirects the user to the login page when a controller action in MVC returns a 401 response, and after the user is signed in and the authentication cookie is created it converts it to the Claims Principal and Claims Identity that you can access in a controller action when you do a .
With this new version of Entity Framework there’s no way to generate the database without using migrations.
For this example we will just use the default Identity User. NET Core Identity is not the only membership system out there, and not only that, it has changed significantly between versions.
Because we need a database to store our membership data we’ll use SQLite (if you you are interested in using a different database check this post: Cross platform database walk-through using ASP. To add SQLite to the project edit project.json’s dependencies and add: (No, it’s not a mistake, you need to add the dependency in both places) The common way to use Identity assumes you will be inheriting from a set of base classes, namely Identity User, so that you can specify what extra information you want to save about your users. So, if you fully commit by tying your user classes and Db Context with ASP.
NET Core then the middleware documentation page and the Dependency Injection documentation pages are good resources to get up to speed about them. First create a Controllers’ folder (the empty template does not have one).