Skip to content

Instantly share code, notes, and snippets.

@natemcmaster
Last active June 1, 2016 00:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save natemcmaster/7311c13aa92dd7f2a297563f21ecb96d to your computer and use it in GitHub Desktop.
Save natemcmaster/7311c13aa92dd7f2a297563f21ecb96d to your computer and use it in GitHub Desktop.
EF design time tools

How EF design-time tooling will work

Package structure

Microsoft.EntityFrameworkCore.Tools
├── lib
│   ├── netcoreapp1.0
│   |   └── dotnet-ef.dll
|   ├── net451
|   |   └── _._
|   └── netcore50
|       └── _._
└── tools
    ├── EntityFrameworkCore.psm1
    └── net451
    |    └── ef.exe
    └── netstandard1.3
         └── ef.dll
         
Microsoft.EntityFrameworkCore.*.Design
--> depends on Microsoft.EntityFrameworkCore.Design

Microsoft.EntityFrameworkCore.Design
└── lib
    └── netstandard1.3
        └── Microsoft.EntityFrameworkCore.Design.dll <-- OperationExecutor

What's different

  • Users must have Microsoft.EntityFrameworkCore.*.Design for their provider.
  • PowerShell forwards to ef.exe on desktop.NET
  • .NET Core CLI and PowerShell share the OperationExecutor
  • ef.dll and ef.exe's only dependencies must be the BCL

How command execution works

.NET Core CLI on .NET Core projects

> dotnet ef $ARGS
  └─ dotnet.exe \
           $NUGET_CACHE/dotnet-ef.dll \
           $ARGS
     |
     |  (Gathers project model info)
     |  (Resolves tool and app dependencies)
     |  (Triggers a build)
     |  (Launches the "inside man")
     |
     └─ dotnet exec \
           --runtimeconfig ef.runtimeconfig.json \
           --depsfile $appname.deps.json \
           $NUGET_CACHE/ef.dll \
           --assembly $full_path_to_appname.dll \
           $ARGS
        |
        |  (Uses command line arguments to identify operation and options)
        |
        └─ OperationExecutor

What's different

  • "dotnet ef" will execute $NUPKG/tools/netstandard1.3/ef.dll instead of $BUILD_OUTPUT/Microsoft.EntityFrameworkCore.Tools.Cli.dll.
  • Ms.EF.Tools no longer needs to be in dependencies
  • dotnet-ef.dll will need to resolve a framework to run and produce a runtimeconfig.json file

.NET Core CLI on .NET Core projects

> dotnet ef $ARGS
  └─ dotnet.exe \
           $NUGET_CACHE/dotnet-ef.dll \
           $ARGS
     |
     |  (Gathers project model info)
     |  (Resolves tool and app dependencies)
     |  (Triggers a build)
     |  (Launches the "inside man")
     |
     └─ $NUGET_CACHE/ef.exe \
           --config ef.exex.config \
           --assembly $full_path_to_appname.dll \
           $ARGS
        |
        |  (Uses command line arguments to identify operation and options)
        |  (Loads user app in sub app-domain)
        |
        └─ OperationExecutor

What's different

  • "dotnet ef" will execute $NUPKG/tools/netstandard1.3/ef.dll instead of $BUILD_OUTPUT/Microsoft.EntityFrameworkCore.Tools.Cli.exe.
  • Ms.EF.Tools no longer needs to be in dependencies in addition to the *.Design assembly

PowerShell on .NET Framework projects

PS > Add-Migration $ARGS
     └─ EntityFrameworkCore.psm1
        |
        |  (Translates cmdlet arguments to dotnet-ef equivalent"
        |
        ├─ "ef.exe $ARGS --json"
        |
        └─ (Parse JSON results and trigger VS window opens)

What's different

  • Powershell cmdlets's only job is to forward to ef.exe and parse json results

PowerShell on .NET Core projects

PS > Add-Migration $ARGS
     └─ EntityFrameworkCore.psm1
        |
        |  (Translates cmdlet arguments to dotnet-ef equivalent"
        |
        ├─ "dotnet ef $ARGS --json"
        |
        └─ (Parse JSON results and trigger VS window opens)

What's different

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