Implementing authentication
There are a lot of built-in functionalities when it comes to authentication. The easiest way to achieve authentication is to just select an authentication option when you create a project, but we are here to learn how things work properly, so we will implement authentication ourselves.
We need to implement authentication separately for the Blazor Server project and the Blazor WebAssembly project because they work a bit differently.
But there are still things we can share between these two projects – first, let's add the necessary tables to our database.
Adding tables to the database
To be able to add authentication, we need to add the necessary tables to our database. This is something we can do using Entity Framework:
- In the
MyBlog.Data
project, we need to add a couple of NuGet packages; right-click on Dependencies and select Manage NuGet Packages. - Search for
Microsoft.AspNetCore.Identity.EntityFrameworkCore
and click...