How to Initialize a Clean ASP.NET Core Project with Entity Framework Core and Identity

Опубликовано: 27 Март 2026
на канале: Zoran on C#
7,678
453

Become a patron and get access to source code and exclusive live streams:   / how-to-clean-asp-81381594  

In this video, you will learn the steps to apply to initialize a brand-new project that utilizes ASP.NET Core Razor pages, backed by Entity Framework Core on the SQL Server, and authenticated using Identity.
The end result of the sequence of steps demonstrated in this video is the Web application project which can evolve using different architectural patterns and styles, yet the project which has all the mandatory elements in place at its outset.
All operations required to initialize the solution and the project, and to add package references to it have been exercised using CLI tools. You can find the list of all commands issued below. Combine this script with the content of the video to bootstrap a new Web application project in time no longer than 5-10 minutes.

Chapters:
00:00 Intro
02:45 Initializing the project
05:27 Setting up the Identity schema
08:37 Adding the domain model and subdomains

Commands to initialize the ASP.NET Razor pages application with Entity Framework Core and Identity:

I Install/update the tools
dotnet tool install -g dotnet-ef
or
dotnet tool update -g dotnet-ef

dotnet tool install -g dotnet-aspnet-codegenerator
or
dotnet tool update -g dotnet-aspnet-codegenerator

II Create the project
dotnet new sln -o SOLUTION_FILE.sln
dotnet new razor -o PROJECT_DIRECTORY
dotnet sln add PROJECT_FILE_PATH

III Add Entity Framework Core packages to the project
dotnet add PROJECT_FILE_PATH package Microsoft.EntityFrameworkCore.Design
dotnet add PROJECT_FILE_PATH package Microsoft.EntityFrameworkCore.SqlServer
dotnet add PROJECT_FILE_PATH package Microsoft.EntityFrameworkCore.Tools

IV Add Identity packages to the project
dotnet add PROJECT_FILE_PATH package Microsoft.VisualStudio.Web.CodeGeneration.Design
dotnet add PROJECT_FILE_PATH package Microsoft.AspNetCore.Identity.EntityFrameworkCore
dotnet add PROJECT_FILE_PATH package Microsoft.AspNetCore.Identity.UI

V Generate Identity pages, migration and update the database
dotnet aspnet-codegenerator identity --project PROJECT_FILE_PATH
dotnet ef migrations add CreateIdentitySchema --project PROJECT_FILE_PATH
dotnet ef database update --project PROJECT_FILE_PATH


Learn more from video courses:
Beginning Object-oriented Programming with C# ► https://codinghelmet.com/go/beginning...
Collections and Generics in C# ► https://codinghelmet.com/go/collectio...
Making Your C# Code More Object-oriented ► https://codinghelmet.com/go/making-yo...

Other courses at Pluralsight ► https://codinghelmet.com/go/pluralsight
Other courses at Udemy ► https://codinghelmet.com/go/udemy

Other videos on this channel you may be interested in watching:
Using GitHub Copilot to Write Complex Code | Step-by-step Tutorial ►    • Using GitHub Copilot to Write Complex Code...  
Coding with GitHub Copilot - Beginner to Master | VS Code Demo ►    • A Comprehensive Guide to GitHub Copilot: F...  
What is Covariance and Contravariance in C# ►    • What is Covariance and Contravariance in C...  
How to Initialize a Clean ASP.NET Core Project with Entity Framework Core and Identity ►    • How to Initialize a Clean ASP.NET Core Pro...  
The Null Conundrum: A Guide to Optional Objects in C# ►    • How to Avoid Null Reference Exceptions: Op...  

#aspnetcore #dotnet #cleancode