Skip to content

Add a REPL for dotnet-ef #35125

@sliekens

Description

@sliekens

I have my DbContext in a class library, so dotnet ef commands always have to be qualified with either a --project or a --startup-project or both, depending where I run the command.

It would be helpful if dotnet ef came with a REPL that remembers these parameters for the duration of a terminal session.

Something like this:

$ dotnet ef interactive --project MyDataAccess
                     _/\__
               ---==/    \\
         ___  ___   |.    \|\
        | __|| __|  |  )   \\\
        | _| | _|   \_/ |  //|\\
        |___||_|       /   \\\/\\

Entity Framework Core REPL

Commands:
  database    Commands to manage the database.
  dbcontext   Commands to manage DbContext types.
  migrations  Commands to manage migrations.

dotnet ef>  migrations add SomeChanges
Build started...
Build succeeded.
Done. To undo this action, use 'migrations remove'

dotnet ef> migrations list
Build started...
Build succeeded.
20241116123911_Initial
20241116125308_SomeChanges

dotnet ef> migrations remove
Build started...
Build succeeded.
Removing migration '20241116125308_SomeChanges'.
Reverting model snapshot.
Done.

dotnet ef>

Possibly, this could be further optimized to skip the project build for side-effect free commands. For example, migrations remove after migrations list does not really need a rebuild since migrations list does not have any side-effects.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions