Skip to content

Commit b25ec3e

Browse files
authored
Improve EF Core breaking change coverage (#34812)
1 parent b25aea1 commit b25ec3e

File tree

1 file changed

+103
-15
lines changed
  • aspnetcore/blazor/tutorials/movie-database-app

1 file changed

+103
-15
lines changed

aspnetcore/blazor/tutorials/movie-database-app/part-2.md

Lines changed: 103 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,27 @@ Paste all of the following commands at the prompt (`>`) of the **Terminal**. Whe
119119

120120
When you paste multiple commands, all of the commands execute except the last one. The last command doesn't execute until you press <kbd>Enter</kbd> on the keyboard.
121121

122+
:::moniker range=">= aspnetcore-10.0"
123+
124+
```dotnetcli
125+
dotnet tool install --global dotnet-aspnet-codegenerator
126+
dotnet tool install --global dotnet-ef
127+
dotnet add package Microsoft.EntityFrameworkCore.SQLite
128+
dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design
129+
dotnet add package Microsoft.EntityFrameworkCore.SqlServer
130+
dotnet add package Microsoft.EntityFrameworkCore.Tools
131+
dotnet add package Microsoft.AspNetCore.Components.QuickGrid
132+
dotnet add package Microsoft.AspNetCore.Components.QuickGrid.EntityFrameworkAdapter
133+
dotnet add package Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore
134+
```
135+
136+
> [!IMPORTANT]
137+
> After the first eight commands execute, make sure that you press <kbd>Enter</kbd> on the keyboard to execute the last command.
138+
139+
:::moniker-end
140+
141+
:::moniker range=">= aspnetcore-9.0 < aspnetcore-10.0"
142+
122143
```dotnetcli
123144
dotnet tool install --global dotnet-aspnet-codegenerator
124145
dotnet tool install --global dotnet-ef
@@ -135,19 +156,42 @@ dotnet add package Microsoft.EntityFrameworkCore.Design
135156
> [!IMPORTANT]
136157
> After the first nine commands execute, make sure that you press <kbd>Enter</kbd> on the keyboard to execute the last command.
137158
138-
> [!NOTE]
139-
> 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**.
140-
141-
Open the app's project file (`BlazorWebAppMovies.csproj`). Drop the `<IncludeAssets>` and `<PrivateAssets>` from the `Microsoft.EntityFrameworkCore.Design` package reference. In the following example, the `{VERSION}` placeholder is the package's version and remains unchanged:
159+
Open the app's project file (`BlazorWebAppMovies.csproj`). Mark the `Microsoft.EntityFrameworkCore.Design` assembly reference as publishable by adding `<Publish>true</Publish>` to the package reference. In the following example, the `{VERSION}` placeholder is the package's version and remains unchanged:
142160

143161
```diff
144-
- <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="{VERSION}">
145-
- <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
146-
- <PrivateAssets>all</PrivateAssets>
147-
- </PackageReference>
148-
+ <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="{VERSION}" />
162+
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="{VERSION}">
163+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
164+
<PrivateAssets>all</PrivateAssets>
165+
+ <Publish>true</Publish>
166+
</PackageReference>
149167
```
150168

169+
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).
170+
171+
:::moniker-end
172+
173+
:::moniker range="< aspnetcore-9.0"
174+
175+
```dotnetcli
176+
dotnet tool install --global dotnet-aspnet-codegenerator
177+
dotnet tool install --global dotnet-ef
178+
dotnet add package Microsoft.EntityFrameworkCore.SQLite
179+
dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design
180+
dotnet add package Microsoft.EntityFrameworkCore.SqlServer
181+
dotnet add package Microsoft.EntityFrameworkCore.Tools
182+
dotnet add package Microsoft.AspNetCore.Components.QuickGrid
183+
dotnet add package Microsoft.AspNetCore.Components.QuickGrid.EntityFrameworkAdapter
184+
dotnet add package Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore
185+
```
186+
187+
> [!IMPORTANT]
188+
> After the first eight commands execute, make sure that you press <kbd>Enter</kbd> on the keyboard to execute the last command.
189+
190+
:::moniker-end
191+
192+
> [!NOTE]
193+
> 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**.
194+
151195
Save the project file.
152196

153197
The preceding commands add:
@@ -175,6 +219,27 @@ Paste all of the following commands at the prompt (`>`) of the command shell. W
175219

176220
When you paste multiple commands, all of the commands execute except the last one. The last command doesn't execute until you press <kbd>Enter</kbd> on the keyboard.
177221

222+
:::moniker range=">= aspnetcore-10.0"
223+
224+
```dotnetcli
225+
dotnet tool install --global dotnet-aspnet-codegenerator
226+
dotnet tool install --global dotnet-ef
227+
dotnet add package Microsoft.EntityFrameworkCore.SQLite
228+
dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design
229+
dotnet add package Microsoft.EntityFrameworkCore.SqlServer
230+
dotnet add package Microsoft.EntityFrameworkCore.Tools
231+
dotnet add package Microsoft.AspNetCore.Components.QuickGrid
232+
dotnet add package Microsoft.AspNetCore.Components.QuickGrid.EntityFrameworkAdapter
233+
dotnet add package Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore
234+
```
235+
236+
> [!IMPORTANT]
237+
> After the first eight commands execute, make sure that you press <kbd>Enter</kbd> on the keyboard to execute the last command.
238+
239+
:::moniker-end
240+
241+
:::moniker range=">= aspnetcore-9.0 < aspnetcore-10.0"
242+
178243
```dotnetcli
179244
dotnet tool install --global dotnet-aspnet-codegenerator
180245
dotnet tool install --global dotnet-ef
@@ -191,16 +256,39 @@ dotnet add package Microsoft.EntityFrameworkCore.Design
191256
> [!IMPORTANT]
192257
> After the first nine commands execute, make sure that you press <kbd>Enter</kbd> on the keyboard to execute the last command.
193258
194-
Open the app's project file (`BlazorWebAppMovies.csproj`). Drop the `<IncludeAssets>` and `<PrivateAssets>` from the `Microsoft.EntityFrameworkCore.Design` package reference. In the following example, the `{VERSION}` placeholder is the package's version and remains unchanged:
259+
Open the app's project file (`BlazorWebAppMovies.csproj`). Mark the `Microsoft.EntityFrameworkCore.Design` assembly reference as publishable by adding `<Publish>true</Publish>` to the package reference. In the following example, the `{VERSION}` placeholder is the package's version and remains unchanged:
195260

196261
```diff
197-
- <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="{VERSION}">
198-
- <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
199-
- <PrivateAssets>all</PrivateAssets>
200-
- </PackageReference>
201-
+ <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="{VERSION}" />
262+
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="{VERSION}">
263+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
264+
<PrivateAssets>all</PrivateAssets>
265+
+ <Publish>true</Publish>
266+
</PackageReference>
202267
```
203268

269+
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).
270+
271+
:::moniker-end
272+
273+
:::moniker range="< aspnetcore-9.0"
274+
275+
```dotnetcli
276+
dotnet tool install --global dotnet-aspnet-codegenerator
277+
dotnet tool install --global dotnet-ef
278+
dotnet add package Microsoft.EntityFrameworkCore.SQLite
279+
dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design
280+
dotnet add package Microsoft.EntityFrameworkCore.SqlServer
281+
dotnet add package Microsoft.EntityFrameworkCore.Tools
282+
dotnet add package Microsoft.AspNetCore.Components.QuickGrid
283+
dotnet add package Microsoft.AspNetCore.Components.QuickGrid.EntityFrameworkAdapter
284+
dotnet add package Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore
285+
```
286+
287+
> [!IMPORTANT]
288+
> After the first eight commands execute, make sure that you press <kbd>Enter</kbd> on the keyboard to execute the last command.
289+
290+
:::moniker-end
291+
204292
Save the project file.
205293

206294
The preceding commands add:

0 commit comments

Comments
 (0)