From c7e3ae0281285cc82c643c982efd2bd6000c9ceb Mon Sep 17 00:00:00 2001 From: Sreeju Date: Wed, 26 Feb 2025 10:27:33 +0300 Subject: [PATCH 1/3] Update static-files.md It is not neccessary to use UseStaticAssets, so documentation must say "The parameterless MapStaticAssets" - --- aspnetcore/fundamentals/static-files.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aspnetcore/fundamentals/static-files.md b/aspnetcore/fundamentals/static-files.md index a70eb721adf9..629c10c8ac68 100644 --- a/aspnetcore/fundamentals/static-files.md +++ b/aspnetcore/fundamentals/static-files.md @@ -62,7 +62,7 @@ The default web app templates call the From b25aea18187881f694fa71459a1c2b95fd662bf8 Mon Sep 17 00:00:00 2001 From: Luke Latham <1622880+guardrex@users.noreply.github.com> Date: Wed, 26 Feb 2025 07:30:08 -0500 Subject: [PATCH 2/3] Add scaffolding troubleshooting remark (#34810) --- aspnetcore/blazor/tutorials/movie-database-app/part-2.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/aspnetcore/blazor/tutorials/movie-database-app/part-2.md b/aspnetcore/blazor/tutorials/movie-database-app/part-2.md index 7bab99f43895..e33c3ff57383 100644 --- a/aspnetcore/blazor/tutorials/movie-database-app/part-2.md +++ b/aspnetcore/blazor/tutorials/movie-database-app/part-2.md @@ -313,6 +313,12 @@ The scaffolding process creates the following component files and movie database The component files in the `MoviePages` folder are described in greater detail in the next part of this tutorial. The database context is described later in this article. +:::zone pivot="vs" + +If the `MoviePages` folder and assets aren't present after scaffolding, return to the [Scaffold the model](#scaffold-the-model) section and rescaffold the `Movie` model, making sure that you select the **Razor Components using Entity Framework (CRUD)** scaffolder under **Installed** > **Common** > **Blazor** > **Razor Component** in the **Add New Scaffold Item** dialog. + +:::zone-end + ASP.NET Core is built with dependency injection, which is a software design pattern for achieving [Inversion of Control (IoC)](/dotnet/standard/modern-web-apps-azure-architecture/architectural-principles#dependency-inversion) between classes and their dependencies. Services, such as the EF Core database context, are registered with dependency injection during application startup. These services are injected into Razor components for use by the components. The [`QuickGrid` component](xref:Microsoft.AspNetCore.Components.QuickGrid) is a Razor component for efficiently displaying data in tabular form. The scaffolder places a `QuickGrid` component in the `Index` component (`Components/Pages/Index.razor`) to display movie entities. Calling on the service collection adds an EF Core adapter for QuickGrid to recognize EF Core-supplied instances and to resolve database queries asynchronously for efficiency. From b25ec3e237e1f96aed730c0f9014404c06665b16 Mon Sep 17 00:00:00 2001 From: Luke Latham <1622880+guardrex@users.noreply.github.com> Date: Wed, 26 Feb 2025 08:16:20 -0500 Subject: [PATCH 3/3] Improve EF Core breaking change coverage (#34812) --- .../tutorials/movie-database-app/part-2.md | 118 +++++++++++++++--- 1 file changed, 103 insertions(+), 15 deletions(-) diff --git a/aspnetcore/blazor/tutorials/movie-database-app/part-2.md b/aspnetcore/blazor/tutorials/movie-database-app/part-2.md index e33c3ff57383..3fc646444c21 100644 --- a/aspnetcore/blazor/tutorials/movie-database-app/part-2.md +++ b/aspnetcore/blazor/tutorials/movie-database-app/part-2.md @@ -119,6 +119,27 @@ Paste all of the following commands at the prompt (`>`) of the **Terminal**. Whe When you paste multiple commands, all of the commands execute except the last one. The last command doesn't execute until you press Enter on the keyboard. +:::moniker range=">= aspnetcore-10.0" + +```dotnetcli +dotnet tool install --global dotnet-aspnet-codegenerator +dotnet tool install --global dotnet-ef +dotnet add package Microsoft.EntityFrameworkCore.SQLite +dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design +dotnet add package Microsoft.EntityFrameworkCore.SqlServer +dotnet add package Microsoft.EntityFrameworkCore.Tools +dotnet add package Microsoft.AspNetCore.Components.QuickGrid +dotnet add package Microsoft.AspNetCore.Components.QuickGrid.EntityFrameworkAdapter +dotnet add package Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore +``` + +> [!IMPORTANT] +> After the first eight commands execute, make sure that you press Enter on the keyboard to execute the last command. + +:::moniker-end + +:::moniker range=">= aspnetcore-9.0 < aspnetcore-10.0" + ```dotnetcli dotnet tool install --global dotnet-aspnet-codegenerator dotnet tool install --global dotnet-ef @@ -135,19 +156,42 @@ dotnet add package Microsoft.EntityFrameworkCore.Design > [!IMPORTANT] > After the first nine commands execute, make sure that you press Enter on the keyboard to execute the last command. -> [!NOTE] -> The preceding commands are .NET CLI commands, and .NET CLI commands are executed when entered at a [PowerShell](/powershell/) prompt, which is the default command shell of the VS Code **Terminal**. - -Open the app's project file (`BlazorWebAppMovies.csproj`). Drop the `` and `` from the `Microsoft.EntityFrameworkCore.Design` package reference. In the following example, the `{VERSION}` placeholder is the package's version and remains unchanged: +Open the app's project file (`BlazorWebAppMovies.csproj`). Mark the `Microsoft.EntityFrameworkCore.Design` assembly reference as publishable by adding `true` to the package reference. In the following example, the `{VERSION}` placeholder is the package's version and remains unchanged: ```diff -- -- runtime; build; native; contentfiles; analyzers; buildtransitive -- all -- -+ + + runtime; build; native; contentfiles; analyzers; buildtransitive + all ++ true + ``` +The preceding update to the package reference is a workaround for a breaking change in .NET 9 EF Core tooling. The change to the package reference can be reverted in apps that are eventually updated to .NET 10 or later. For more information, see [Breaking changes in EF Core 9 (EF9)](/ef/core/what-is-new/ef-core-9.0/breaking-changes#microsoftentityframeworkcoredesign-not-found-when-using-ef-tools). + +:::moniker-end + +:::moniker range="< aspnetcore-9.0" + +```dotnetcli +dotnet tool install --global dotnet-aspnet-codegenerator +dotnet tool install --global dotnet-ef +dotnet add package Microsoft.EntityFrameworkCore.SQLite +dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design +dotnet add package Microsoft.EntityFrameworkCore.SqlServer +dotnet add package Microsoft.EntityFrameworkCore.Tools +dotnet add package Microsoft.AspNetCore.Components.QuickGrid +dotnet add package Microsoft.AspNetCore.Components.QuickGrid.EntityFrameworkAdapter +dotnet add package Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore +``` + +> [!IMPORTANT] +> After the first eight commands execute, make sure that you press Enter on the keyboard to execute the last command. + +:::moniker-end + +> [!NOTE] +> The preceding commands are .NET CLI commands, and .NET CLI commands are executed when entered at a [PowerShell](/powershell/) prompt, which is the default command shell of the VS Code **Terminal**. + Save the project file. The preceding commands add: @@ -175,6 +219,27 @@ Paste all of the following commands at the prompt (`>`) of the command shell. W When you paste multiple commands, all of the commands execute except the last one. The last command doesn't execute until you press Enter on the keyboard. +:::moniker range=">= aspnetcore-10.0" + +```dotnetcli +dotnet tool install --global dotnet-aspnet-codegenerator +dotnet tool install --global dotnet-ef +dotnet add package Microsoft.EntityFrameworkCore.SQLite +dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design +dotnet add package Microsoft.EntityFrameworkCore.SqlServer +dotnet add package Microsoft.EntityFrameworkCore.Tools +dotnet add package Microsoft.AspNetCore.Components.QuickGrid +dotnet add package Microsoft.AspNetCore.Components.QuickGrid.EntityFrameworkAdapter +dotnet add package Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore +``` + +> [!IMPORTANT] +> After the first eight commands execute, make sure that you press Enter on the keyboard to execute the last command. + +:::moniker-end + +:::moniker range=">= aspnetcore-9.0 < aspnetcore-10.0" + ```dotnetcli dotnet tool install --global dotnet-aspnet-codegenerator dotnet tool install --global dotnet-ef @@ -191,16 +256,39 @@ dotnet add package Microsoft.EntityFrameworkCore.Design > [!IMPORTANT] > After the first nine commands execute, make sure that you press Enter on the keyboard to execute the last command. -Open the app's project file (`BlazorWebAppMovies.csproj`). Drop the `` and `` from the `Microsoft.EntityFrameworkCore.Design` package reference. In the following example, the `{VERSION}` placeholder is the package's version and remains unchanged: +Open the app's project file (`BlazorWebAppMovies.csproj`). Mark the `Microsoft.EntityFrameworkCore.Design` assembly reference as publishable by adding `true` to the package reference. In the following example, the `{VERSION}` placeholder is the package's version and remains unchanged: ```diff -- -- runtime; build; native; contentfiles; analyzers; buildtransitive -- all -- -+ + + runtime; build; native; contentfiles; analyzers; buildtransitive + all ++ true + ``` +The preceding update to the package reference is a workaround for a breaking change in .NET 9 EF Core tooling. The change to the package reference can be reverted in apps that are eventually updated to .NET 10 or later. For more information, see [Breaking changes in EF Core 9 (EF9)](/ef/core/what-is-new/ef-core-9.0/breaking-changes#microsoftentityframeworkcoredesign-not-found-when-using-ef-tools). + +:::moniker-end + +:::moniker range="< aspnetcore-9.0" + +```dotnetcli +dotnet tool install --global dotnet-aspnet-codegenerator +dotnet tool install --global dotnet-ef +dotnet add package Microsoft.EntityFrameworkCore.SQLite +dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design +dotnet add package Microsoft.EntityFrameworkCore.SqlServer +dotnet add package Microsoft.EntityFrameworkCore.Tools +dotnet add package Microsoft.AspNetCore.Components.QuickGrid +dotnet add package Microsoft.AspNetCore.Components.QuickGrid.EntityFrameworkAdapter +dotnet add package Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore +``` + +> [!IMPORTANT] +> After the first eight commands execute, make sure that you press Enter on the keyboard to execute the last command. + +:::moniker-end + Save the project file. The preceding commands add: