Skip to content

Instantly share code, notes, and snippets.

@joacar
Last active June 28, 2018 17:14
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 joacar/09009f863ce9a268eaa6b512ab1c9f4c to your computer and use it in GitHub Desktop.
Save joacar/09009f863ce9a268eaa6b512ab1c9f4c to your computer and use it in GitHub Desktop.
dotnet ef command line helper files
@echo off
if "%~1"=="" (
set /p "migration=Migration name is required. Enter name: "
)
if "%migration%"=="" ( exit /b )
set "filepath=%~2"
REM Content file is just one line as "-c MyDdContext -p Path/To/Project.csproj -o Path/To/Migrations
if "%~2"=="" (
set /p "filepath=Args content file required: Enter name:"
)
REM Read file content
set /p args=<%filepath%
pushd %~dp0src\WebApp
echo on
dotnet ef migrations add %migration% %args%
@echo off
popd %~dp0
@echo off
set "filepath=%~1"
REM Set your default file here if wanted
if "%filepath%"=="" ( set "filepath=<DEFAULT_FILE>" )
echo Using file '%filepath%' as default
REM Read file content
set /p args=<%filepath%
pushd %~dp0src\WebApp
echo on
dotnet ef migrations remove %args%
@echo off
popd %~dp0
@echo off
if "%~1"=="" ( set /p "migration=Migration name: " ) else (set "%migration=%~1")
if "%migration%"=="" ( exit /b )
set "filepath=%~2"
if "%~2"=="" (
set /p "ctx=Db context to update: "
)
pushd %~dp0src\WebApp
echo on
dotnet ef database update -c %ctx% %migration%
@echo off
popd %~dp0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment