Skip to content

Add support for file-based apps to dotnet-ef tools#38157

Merged
AndriySvyryd merged 9 commits intodotnet:mainfrom
jjonescz:fba
Apr 24, 2026
Merged

Add support for file-based apps to dotnet-ef tools#38157
AndriySvyryd merged 9 commits intodotnet:mainfrom
jjonescz:fba

Conversation

@jjonescz
Copy link
Copy Markdown
Member

@jjonescz jjonescz commented Apr 23, 2026

Resolves #38158.

  • I've read the guidelines for contributing and seen the walkthrough
  • I've posted a comment on an issue with a detailed description of how I am planning to contribute and got approval from a member of the team
  • The code builds and tests pass locally (also verified by our automated build checks)
  • Commit messages follow this format:
        Summary of the changes
        - Detail 1
        - Detail 2

        Fixes #bugnumber
  • Tests for the changes have been added (for bug fixes / features)
  • Code follows the same patterns and style as existing code in this repo

@roji
Copy link
Copy Markdown
Member

roji commented Apr 23, 2026

@jjonescz can you please open an issue clearly detailing what this is meant to fix?

Comment thread test/dotnet-ef.Tests/FileBasedAppTest.cs Outdated
@jjonescz jjonescz marked this pull request as ready for review April 23, 2026 15:05
@jjonescz jjonescz requested a review from a team as a code owner April 23, 2026 15:05
Copilot AI review requested due to automatic review settings April 23, 2026 15:05
Copy link
Copy Markdown

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 adds first-class support in dotnet-ef for “file-based apps” (single .cs files) by allowing users to point tooling at a .cs file and ensuring metadata extraction works for those inputs.

Changes:

  • Add a --file option (mutually exclusive with --project) and resolve it when selecting the project path.
  • Switch MSBuild metadata extraction to use dotnet build (instead of dotnet msbuild) when the input is a .cs file.
  • Add a new test validating build/metadata extraction for a file-based app.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
test/dotnet-ef.Tests/FileBasedAppTest.cs New test covering metadata extraction and build output for a .cs file-based app.
src/dotnet-ef/RootCommand.cs Adds --file handling and mutual exclusion logic with --project.
src/dotnet-ef/Properties/Resources.resx Adds new option/error strings and updates option descriptions.
src/dotnet-ef/Properties/Resources.Designer.cs Updates strongly-typed resource accessors for new strings.
src/dotnet-ef/ProjectOptions.cs Adds the --file command-line option.
src/dotnet-ef/Project.cs Uses dotnet build (vs dotnet msbuild) for .cs inputs during metadata extraction.
Files not reviewed (1)
  • src/dotnet-ef/Properties/Resources.Designer.cs: Language not supported

Comment thread test/dotnet-ef.Tests/FileBasedAppTest.cs Outdated
Comment thread src/dotnet-ef/RootCommand.cs Outdated
@AndriySvyryd AndriySvyryd self-assigned this Apr 23, 2026
Comment thread src/dotnet-ef/Project.cs Outdated
Copilot AI review requested due to automatic review settings April 23, 2026 17:09
Copy link
Copy Markdown

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

Copilot reviewed 5 out of 6 changed files in this pull request and generated 1 comment.

Files not reviewed (1)
  • src/dotnet-ef/Properties/Resources.Designer.cs: Language not supported

Comment thread test/dotnet-ef.Tests/ProjectTest.cs
@AndriySvyryd
Copy link
Copy Markdown
Member

I think we shouldn't introduce --file. Adding support for file-based apps doesn't change the overall semantics of the input: --project indicates the code that when compiled produces an assembly with migrations, --startup-project indicates the code that when compiled produces an assembly that contains EF configuration (.AddDbContext),

@jjonescz
Copy link
Copy Markdown
Member Author

jjonescz commented Apr 23, 2026

Right, so you are saying we should accept .cs files as arguments to --project and --startup-project? That works for me. I was trying to be more consistent with other commands (e.g., dotnet run has also --project and --file arguments, and some other dotnet CLI commands are also like that). But we could definitely add the file option later, and can start with accepting the file as project now.

@AndriySvyryd
Copy link
Copy Markdown
Member

Right, so you are saying we should accept .cs files as arguments to --project and --startup-project? That works for me. I was trying to be more consistent with other commands (e.g., dotnet run has also --project and --file arguments, and some other dotnet CLI commands are also like that). But we could definitely add the file option later, and can start with accepting the file as project now.

Yes. We could add --file and --startup-file as synonyms, I just think that would be confusing for users familiar with dotnet-ef

Copilot AI review requested due to automatic review settings April 23, 2026 18:09
Copy link
Copy Markdown

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

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

Files not reviewed (1)
  • src/dotnet-ef/Properties/Resources.Designer.cs: Language not supported

Comment thread test/dotnet-ef.Tests/FileBasedAppTest.cs Outdated
Comment thread test/dotnet-ef.Tests/FileBasedAppTest.cs Outdated
Comment thread src/dotnet-ef/Project.cs
@AndriySvyryd
Copy link
Copy Markdown
Member

Filed #38159 to decide which direction we should go

Copy link
Copy Markdown
Member

@AndriySvyryd AndriySvyryd left a comment

Choose a reason for hiding this comment

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

Thanks!

@AndriySvyryd AndriySvyryd merged commit c0e491b into dotnet:main Apr 24, 2026
23 checks passed
@jjonescz jjonescz deleted the fba branch April 25, 2026 09:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dotnet-ef tools should support file-based apps

4 participants