You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: entity-framework/core/cli/msbuild.md
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
title: EF Core MSBuild tasks - EF Core
3
3
description: Reference guide for the Entity Framework Core .NET MSBuild tasks
4
4
author: AndriySvyryd
5
-
ms.date: 11/08/2024
5
+
ms.date: 01/17/2025
6
6
uid: core/cli/msbuild
7
7
---
8
8
@@ -40,6 +40,7 @@ If the project specifies `<PublishAot>true</PublishAot>` then by default the MSB
40
40
41
41
## Limitations
42
42
43
+
* When using the integration during the `publish` stage also set the rid in the startup project (e.g. \<RuntimeIdentifier\>win-x64\</RuntimeIdentifier\>)
43
44
* A different startup project cannot be specified when using this approach as it would introduce an inverse build dependency. This means that the context project needs to be autosuficient in terms of configuration, so if your app normally configures the context using a host builder in a different project you'd need to [implement _IDesignTimeDbContextFactory<TContext>_](xref:core/cli/dbcontext-creation#from-a-design-time-factory) in the context project.
44
45
* Since the project needs to be compilable before the compiled model is generated this approach doesn't support partial method implementations for customization of the compiled model.
45
46
* Currently, this will always generate additional code in the compiled model that's required for NativeAOT. If you are not planning to enable NativeAOT then [generate the compiled model using the CLI tools](xref:core/cli/dotnet#optimize).
Copy file name to clipboardExpand all lines: entity-framework/core/miscellaneous/internals/tools.md
+2-7Lines changed: 2 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
title: Design-time Tools Architecture - EF Core
3
3
description: The architecture of design-time tools in Entity Framework Core
4
4
author: SamMonoRT
5
-
ms.date: 11/27/2023
5
+
ms.date: 01/17/2025
6
6
uid: core/miscellaneous/internals/tools
7
7
---
8
8
# Design-time Tools Architecture
@@ -23,12 +23,7 @@ There are two primary inputs to this command: the startup project and the target
23
23
24
24
It reads information about the projects by injecting an MSBuild .targets file and calling the custom MSBuild target. The .targets file is compiled into dotnet-ef as an embedded resource. The source is located at [src/dotnet-ef/Resources/EntityFrameworkCore.targets](https://github.com/dotnet/efcore/blob/main/src/dotnet-ef/Resources/EntityFrameworkCore.targets).
25
25
26
-
It has a bit of logic at the beginning to handle multi-targeting projects. Essentially, it just picks the first target framework and re-invokes itself. After a single target framework has been determined, it writes several MSBuild properties like AssemblyName, OutputPath, RootNamespace, etc. to a temporary file that dotnet-ef then reads.
27
-
28
-
> [!TIP]
29
-
> .NET 8 adds a new, streamlined way to read MSBuild properties that will enable us to remove this .targets file. See issue [#32113](https://github.com/dotnet/efcore/issues/32113).
30
-
31
-
We need to inject this target into both the startup and target project. We do that by leveraging an MSBuild hook created for NuGet and other package managers. That hook automatically loads any file under `$(MSBuildProjectExtensionsPath)` with a name matching the pattern `$(MSBuildProjectName).*.targets`. Unfortunately, we don't know the actual value of the MSBuildProjectExtensionsPath property, and we need it before we can read any MSBuild properties. So, we assume it's set to the default value of `$(MSBuildProjectDirectory)\obj`. If it's not, the user must specify it using the `--msbuildprojectextensionspath` option.
26
+
It has a bit of logic at the beginning to handle multi-targeting projects. Essentially, it just picks the first target framework and re-invokes itself. After a single target framework has been determined, it gets several MSBuild properties like AssemblyName, OutputPath, RootNamespace, etc.
32
27
33
28
After we've collected the project information, we compile the startup project. We assume that the target project will also be compiled transitively.
Starting with .NET SDK 9.0.200 an exception is thrown when an EF tool is invoked:
140
+
> :::no-loc text="Could not load file or assembly 'Microsoft.EntityFrameworkCore.Design, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.":::
141
+
142
+
#### Why
143
+
144
+
EF tools were relying on an undocumented behavior of .NET SDK that caused private assets to be included in the generated `.deps.json` file. This was fixed in [sdk#45259](https://github.com/dotnet/sdk/pull/45259). Unfortunately, the EF change to account for this doesn't meet the servicing bar for EF 9.0.x, so it will be fixed in EF 10.
145
+
146
+
#### Mitigations
147
+
148
+
As a workaround before EF 10 is released you can mark the `Design` assembly reference as publishable:
This will include it in the generated `.deps.json` file, but has a side effect of copying `Microsoft.EntityFrameworkCore.Design.dll` to the output and publish folders.
0 commit comments