18 Creating the example project

 

This chapter covers

  • Creating an ASP.NET Core project
  • Creating a simple data model
  • Adding Entity Framework Core to the ASP.NET Core project
  • Creating and applying an Entity Framework Core migration
  • Adding the Bootstrap CSS package to the project
  • Defining a simple request pipeline configuration

In this chapter, you will create the example project used throughout this part of the book. The project contains a simple data model, a client-side package for formatting HTML content, and a simple request pipeline.

18.1 Creating the project

Open a new PowerShell command prompt and run the commands shown in listing 18.1.

Tip

You can download the example project for this chapter—and for all the other chapters in this book—from https://github.com/manningbooks/pro-asp.net-core-7. See chapter 1 for how to get help if you have problems running the examples.

Listing 18.1 Creating the project
dotnet new globaljson --sdk-version 7.0.100 --output WebApp
dotnet new web --no-https --output WebApp --framework net7.0
dotnet new sln -o WebApp
dotnet sln WebApp add WebApp

If you are using Visual Studio, open the WebApp.sln file in the WebApp folder. If you are using Visual Studio Code, open the WebApp folder. Click the Yes button when prompted to add the assets required for building and debugging the project, as shown in figure 18.1.

Figure 18.1 Adding project assets

18.2 Adding a data model

18.2.1 Adding NuGet packages to the project

18.2.2 Creating the data model

18.2.3 Preparing the seed data

18.2.4 Configuring EF Core services and middleware

18.2.5 Creating and applying the migration

18.3 Adding the CSS framework

18.4 Configuring the request pipeline

18.5 Running the example application