Skip to content

Conversation

@AndriySvyryd
Copy link
Member

@AndriySvyryd AndriySvyryd commented Dec 4, 2025

Fixes #37230

Description
For EF 10 we started relying on the ResolvePackageAssets MSBuild task to get more accurate information about the project dependencies. However, this task is not available if the project is targeting multiple TFMs. The solution is to allow users to select which framework should be used.
This will be documented as a breaking change: dotnet/EntityFramework.Docs#5200

Customer impact
For apps targeting multiple TFMs the ef tool will throw an exception when any command is invoked. The workaround to change the project to target a single TFM temporarily. However, this isn't possible in CI/CD scenarios.

How found
Multiple customer reports on EF 10.

Regression
Yes, from EF 9

Testing
Tested manually.

Risk
Low. Targeted fix that only affects design-time tools.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes an issue where the dotnet ef tool fails for projects targeting multiple target frameworks (multi-TFM). The fix passes framework, configuration, and runtime parameters to Project.FromFile() for both the main project and startup project, and adds a helpful error message when multi-TFM projects are detected without a specified framework.

Key changes:

  • Modified RootCommand.cs to pass framework/configuration/runtime parameters to both project and startup project initialization
  • Added HasMultipleTargetFrameworks() helper method to detect multi-TFM scenarios and provide a clear error message
  • Added MultipleTargetFrameworks resource string for the new error message

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/dotnet-ef/RootCommand.cs Updated to pass framework/configuration/runtime parameters to Project.FromFile() for the main project, matching the existing startup project initialization
src/dotnet-ef/Properties/Resources.resx Added new error message resource for multi-TFM scenario
src/dotnet-ef/Properties/Resources.Designer.cs Generated code for new resource string and minor documentation improvement for NativeAotDescription
src/dotnet-ef/Project.cs Added HasMultipleTargetFrameworks() method to detect multi-TFM projects and improved error handling with specific message
Files not reviewed (1)
  • src/dotnet-ef/Properties/Resources.Designer.cs: Language not supported

@AndriySvyryd AndriySvyryd changed the title [release/10.0] Fix empty scalar collection support (#37248) [release/10.0] Allow tools to run on projects targeting multiple frameworks Dec 4, 2025
@rfrerebe-stx
Copy link

Hello,

Looking at your commit, I see that you are suggesting that an additional option --framework net10.0 should be used.
Unfortunately it don't seems to work on my repro

❯ dotnet ef migrations list --framework net10.0
D:\DEV\dotnet\ef10tools-repro2\Ef10ToolsRepro.csproj : error MSB4057: The target "ResolvePackageAssets" does not exist in the project.
Build failed. Properties, Items, and Target results cannot be obtained. See details in stderr above.
Unable to retrieve project metadata. Ensure it's an SDK-style project.

Could you please confirm how to fix this issue ?

@AndriySvyryd
Copy link
Member Author

AndriySvyryd commented Dec 8, 2025

@rfrerebe-stx It will work after this change is merged, see the fix in https://github.com/dotnet/efcore/pull/37301/files#diff-ef9188d23e289a8c4dbaa9d76aea973b8a91110fb3e21e4816953338e28ebf2f

@SamMonoRT
Copy link
Member

SamMonoRT commented Dec 9, 2025

cc @artl93 - With cutoff date tomorrow, please review so this can proceed to tactics today

@SamMonoRT SamMonoRT added this to the 10.0.2 milestone Dec 9, 2025
@artl93
Copy link
Member

artl93 commented Dec 9, 2025

@AndriySvyryd - can you clarify how the tooling change will impact CI/CD? It sounds like we're still forcing the user to make a choice. Is this the fix we'd want in the fullness of time?

@AndriySvyryd
Copy link
Member Author

@artl93 This will be documented as a breaking change. I do think this is the right behavior going forward, as previously there have been reports of tools running successfully locally but failing in CI/CD because of the implicitly chosen TFM.

Copy link
Member

@artl93 artl93 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving, though the breaking change doc would be great to see.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants