From 6a7ad7ae2cc1d94ec13c83261676fb65e208cc24 Mon Sep 17 00:00:00 2001 From: Yam1x Date: Fri, 25 Jul 2025 16:49:55 +0500 Subject: [PATCH 1/3] ci: add dotnet feature and install dotnet-ef tool to be able to use migrations --- .devcontainer/devcontainer.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 1cac1b0..81fab1f 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -2,12 +2,16 @@ // README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-dockerfile { "name": "Existing Dockerfile", + "onCreateCommand": "dotnet tool install --global dotnet-ef", "build": { // Sets the run context to one level up instead of the .devcontainer folder. "context": "..", // Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename. "dockerfile": "../KarateDockerfile" }, + "features": { + "ghcr.io/devcontainers/features/dotnet:2": {} + }, "runArgs": [ "--network=host" ], From c634b332b8b60269da1090acda6807ab87a5bd02 Mon Sep 17 00:00:00 2001 From: Yam1x Date: Mon, 28 Jul 2025 08:32:13 +0500 Subject: [PATCH 2/3] docs: add instructions about creating the migrations via VS Code and dotnet ef tool --- README.md | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e47e48e..61eb5c2 100644 --- a/README.md +++ b/README.md @@ -2,13 +2,14 @@ ## Migrations -### Adding a new migration (Windows via Visual Studio) +### Adding a new migration -Run the database using doocker compose executing the following script +Run the database using docker compose executing the following script ```bash docker compose --profile db-only up -d ``` +#### Visual Studio After making changes to the model and AppDbContext open Tools -> NuGet Package Manager -> Package Manager Console Execute the following with your migration name @@ -20,3 +21,17 @@ To apply migration run the following: ```bash Update-Database -Project Application ``` + +#### VS Code + +Open project in the devcontainer and open Terminal -> New Terminal + +Execute the following with your migration name +```bash +dotnet ef migrations add --startup-project Api/ --project Application/ -- --environment MockForDevelopment +``` + +To apply migration run the following: +```bash +dotnet ef database update --startup-project Api/ --project Application/ -- --environment MockForDevelopment +``` From 2a8480b3fb198198cf196f46ffa5aed81668ce0a Mon Sep 17 00:00:00 2001 From: Yam1x Date: Mon, 28 Jul 2025 13:18:47 +0500 Subject: [PATCH 3/3] ci: set versions for dotnet devcontainer feature and dotnet-ef tool --- .devcontainer/devcontainer.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 81fab1f..7be6469 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -2,7 +2,7 @@ // README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-dockerfile { "name": "Existing Dockerfile", - "onCreateCommand": "dotnet tool install --global dotnet-ef", + "onCreateCommand": "dotnet tool install --global dotnet-ef --version 9.0.7", "build": { // Sets the run context to one level up instead of the .devcontainer folder. "context": "..", @@ -10,7 +10,9 @@ "dockerfile": "../KarateDockerfile" }, "features": { - "ghcr.io/devcontainers/features/dotnet:2": {} + "ghcr.io/devcontainers/features/dotnet:2": { + "version": "9.0.303" + } }, "runArgs": [ "--network=host"