Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,40 @@ dotnet new ssw-ca --name {{SolutionName}} --output .\

3. Open https://localhost:7255/scalar/v1 in your browser to see it running ️🏃‍♂️

### EF Migrations
Due to .NET Aspire orchestrating the application startup and migration runner, EF migrations need to be handled a little differently to normal.

#### Adding a Migration
Adding new migrations is still the same old command you would expect, but with a couple of specific parameters to account for the separation of concerns:

1. Run the following command from the root of the solution.

```bash
dotnet ef migrations add YourMigrationName --project ./src/Infrastructure/Infrastructure.csproj --startup-project ./src/WebApi/WebApi.csproj --output-dir ./Persistence/Migrations
```

#### Applying a Migration
.NET Aspire handles this for you - just start the project!

#### Removing a Migration
This is where things need to be done a little differently.

1. Install the [.NET Aspire CLI](https://learn.microsoft.com/en-us/dotnet/aspire/fundamentals/setup-tooling)

2. Enable the `exec` function:

```bash
aspire config set features.execCommandEnabled true
```

3. Pass the EF migration shell command through Aspire from the root of the solution:

```bash
aspire exec --resource api -- dotnet ef migrations remove --project ..\Infrastructure --force
```
> [!NOTE]
> The `--force` flag is needed because .NET Aspire will start the application when this command is run, which triggers the migrations to run. This will apply your migrations to the database, and make EF Core unhappy when it tries to delete the latest migration. This should therefore be used with caution - a safer approach is to "roll forward" and create new migrations that safely undo the undesired change(s).

## Deploying to Azure

The template can be deployed to Azure via
Expand Down