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

preview_player
Показать описание

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:

Other videos on this channel you may be interested in watching:

#aspnetcore #dotnet #cleancode
Рекомендации по теме
Комментарии
Автор

Brilliant points. What you are guaranteed to get from Zoran is always:
- Amazing eloquence and clarity of communication that seemingly effortlessly come from astounding amount or theoretical and practical knowledge
- Rational, no-nonsense and efficient approach to attacking problems which obviously comes from huge experience along with constant application of a profoundly sharp mind

Absolutely love your content Zoran.

Srecni novogodisnji praznici i sve najbolje u Novoj.

johnvonninamann
Автор

Pretty good stuff, Zoran! Thank you!!

marcio_zani
Автор

Wonderful tips to quickly get up and running, would like more videos like these. Like the little and quick hack for the Auth when in dev mode.

anthonyliljegren
Автор

Awesome stuff man, simple, easy and high-customizable. Further ahead if working with microservices, the user will probably need to separate the backend stuff in another layers of management, including diferent projects. But for a clean start is a good and clear way of thinking! #thumbsUP

ericroberto
Автор

KISS and YAGNI are always the hardest rules to learn to apply 😁 time and time again we are surprised by our ability to forget about these principles

wojciechwilimowski
Автор

Making my way through your reading list on your coding helmet website. Excellent content as always Zoran! Thank for generosity and for moving the state of software development in the right direction 😊

bjk