---
url: /saas-starter/v0.10.0/upgrading.md
---
# Upgrading an app

An app made with `dotnet new saas-starter` is your code, not a package: updating the template
(`dotnet new update`) changes only apps you create afterwards. To bring an existing app up to a
later version, you apply the template's changes to it as a patch, then resolve whatever clashes
with your own changes, as you would when merging a branch.

## 1. Read what changed

Each version's [release notes](../releases/) list the changes to know about: renamed types,
changed endpoints, new settings, and database migrations. The guides on this site (in the
sidebar) go through each upgrade step by step. Go one version at a time when you're several
behind: each step is smaller, and its guide applies.

## 2. Make a patch for your app

[`upgrade-patch.sh`](https://libresharp.github.io/saas-starter/latest/upgrade-patch.sh) generates your app twice, at the version you have and the
one you want, with your app's name and the options you chose, and writes the difference as a
patch. It needs the .NET SDK and git, and leaves the template you have installed alone.

```bash
curl -fsSLO https://libresharp.github.io/saas-starter/latest/upgrade-patch.sh
chmod +x upgrade-patch.sh
```

An app created from v0.9.0 or later records the template version, its name and the options it was
created with in `.saas-starter.json`, at its root. Run the script there with the version you want:

```bash
./upgrade-patch.sh 0.10.0
```

Without `.saas-starter.json`, give both versions, the app's name, and the options you used with
`dotnet new` (the defaults are `--Persistence marten --Auth saas --IncludeTests true --Aspire
false`), for example `./upgrade-patch.sh 0.9.0 0.10.0 MyApp --Persistence efcore`.

The patch covers everything the template changed: code, tests, docs, package versions and, with EF
Core, migrations.

On Windows, run it in Git Bash or WSL.

## 3. Apply it

On a clean working tree, at the root of your app's repository:

```bash
git switch -c upgrade-to-0.10.0
git apply -3 upgrade.patch
git status
```

`-3` merges each file the way `git merge` would, so your changes stay. Files you changed in the
same places as the template are left with conflict markers to resolve. That works when your
history still has the files as first generated: commit the app before changing it.

If `git apply` can't find a file's original (`repository lacks the necessary blob`), that file
was changed before its first commit. Apply the rest with `git apply -3 --reject upgrade.patch`
and copy that file's changes across by hand from the `.rej` file.

## 4. Check it

```bash
dotnet build
dotnet test
dotnet run --project src/MyApp                                  # leave it running, then in a second terminal:
cd src/Client && npm install && npm run gen:api && npm run lint && npm test
```

* **Regenerate the API client** (`npm run gen:api`, with the API running) rather than resolving
  conflicts in `src/Client/src/lib/api/schema.d.ts` by hand: it's generated from your API.
* **EF Core:** if you added migrations of your own, `AppDbContextModelSnapshot.cs` will conflict.
  Keep both sides' entities, then check that the snapshot matches the model:
  `dotnet ef migrations has-pending-model-changes --project src/MyApp`. The template's new
  migrations are applied at startup, like yours.
* **Marten** updates its tables itself when the app starts, in every environment: there's nothing
  to run. Back up the database before deploying an upgrade, as with any release.
* **Read the version's guide** for changes the compiler won't catch, such as new settings and
  changed defaults.

## Upgrade guides

* [To v0.10.0](./v0.10.0.md): separate handler chains, xUnit v3, and the security review's
  changes to passwords, sessions and cookies.

Guides start with v0.10.0. Earlier versions have release notes only: use the patch and the notes'
"Changes to know about".
