Let's dive into the code:
- First, create a new project by running the following scripts in Command Prompt / Terminal:
dotnet new web -n AspNetCoreIdentitySample dotnet restore
- Open Startup.cs file, and change the ConfigureServices() method, as follows:
public void ConfigureServices(IServiceCollection services) { services.AddDbContext<ApplicationDbContext>(options => options.UseSqlServer("Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=AspNetCoreIdentitySample;Data Source=.")); services.AddIdentity<ApplicationUser, IdentityRole>() .AddEntityFrameworkStores<ApplicationDbContext>() .AddDefaultTokenProviders(); services.AddMvc(); }
- We set up the connection string and point that to our local database ...