---
url: /saas-starter/v0.10.1/guide/generate.md
---
# Generate an app

The template creates a complete app from one command. Its options decide what goes in it: whether
it has accounts and organisations, how it stores data, and whether it comes with tests and an Aspire
AppHost. What you get is your own code, with only the parts you chose: there's no package to update
later, and nothing to switch off.

## The command

Install the template once, then generate an app with the options you want:

```bash
dotnet new install LibreSharp.Templates.SaasStarter
dotnet new saas-starter -n MyApp --Auth identity --Persistence efcore
cd MyApp
git init && git add -A && git commit -m "Generated from LibreSharp.Templates.SaasStarter"
```

Leave an option out to take its default. `dotnet new saas-starter --help` lists them, and
[Get started](../getting-started.md) has what you need installed first.

## The options

| Option | Values | Default | What it decides |
|---|---|---|---|
| [`--Auth`](#auth) (`-A`) | `none`, `identity`, `saas` | `saas` | Accounts, and whether they belong to organisations |
| [`--Persistence`](#persistence) (`-P`) | `marten`, `efcore` | `marten` | How data is stored in PostgreSQL |
| [`--IncludeTests`](#includetests) (`-I`) | `true`, `false` | `true` | The API and end-to-end tests |
| [`--Aspire`](#aspire) (`-As`) | `true`, `false` | `false` | An Aspire AppHost that starts everything for development |
| [`--DisplayName`](#displayname) (`-D`) | text | the `-n` name | The name people see |

`-n` gives the app's name, used for its solution, project, namespaces and container image (a C#
name, such as `MyApp` or `Acme.Crm`; the current folder's name if you leave it out). `-o` says
where to put it (a folder named after the app by default).

Every combination is built and tested in the template's CI on every change, so any of them is a
working app.

## Accounts and organisations: `--Auth` {#auth}

How much of a SaaS app you get. Each choice adds to the one before.

### No accounts

```bash
dotnet new saas-starter -n MyApp --Auth none
```

For an internal tool, or to start small and add sign-in yourself. Everyone shares the same data.

* **The Todo example:** endpoints, validation, a background handler, scheduled reminders and live
  updates over SignalR, to copy for your own features.
* **Messaging:** a transactional outbox and durable queues.
* **File storage:** local disk, any S3-compatible store or Azure Blob Storage.
* **Production:** a container image, Docker Compose with Caddy, health checks, OpenTelemetry and
  strict security headers.

### Accounts

```bash
dotnet new saas-starter -n MyApp --Auth identity
```

For an app where each person has their own data. Everything under **No accounts**, and:

* **Sign-in:** email and password, passkeys, Google and GitHub, two-factor authentication.
* **Account security:** email confirmation, sessions, lockout, and emails about new devices and
  changes.
* **Settings:** profile picture, email, password, sign-in methods, notifications, download your
  data, delete the account.
* **Back office:** users, roles, invitations, an audit log, and failed messages to replay.

### Accounts and organisations&#x20;

```bash
dotnet new saas-starter -n MyApp
```

For a SaaS sold to teams: data belongs to an organisation, not a person. Everything under
**Accounts**, and:

* **Organisations:** each account gets one; members with Owner, Admin and Member roles,
  invitations by email, a switcher, and data kept apart per organisation.
* **Billing:** plans, a reverse trial, features and limits per plan, and Stripe Checkout, the
  customer portal and webhooks.
* **Integrations:** API keys, an MCP endpoint for AI assistants, signed webhooks, and encrypted
  secrets.
* **Back office:** organisations, revenue and feature flags too.

Not sure? Take the smallest that covers what you'll need in the first months. Adding organisations
to an app later means moving its data under them, so if you'll sell to teams, start with `saas`.

## Data: `--Persistence` {#persistence}

Both store everything in PostgreSQL, and both run the same features, tests and docs. They differ in
how you write data access.

| | `marten` (default) | `efcore` |
|---|---|---|
| **What it is** | [Marten](https://martendb.io/): documents stored as JSON, and event sourcing | Entity Framework Core: classes mapped to tables |
| **Schema changes** | None to write: Marten updates its tables when the app starts | A migration for each change, applied when the app starts ([how](./how-to/add-a-migration.md)) |
| **The Todo example** | Each Todo is an event stream, with a snapshot to query | Each Todo is a row |
| **Choose it when** | You want to move fast, or keep a history of changes | Your team knows EF Core, or you want a relational schema to report on |

## Tests: `--IncludeTests` {#includetests}

With `true` (the default), the app has `tests/ApiHost.Tests`, which runs the real app against a
throwaway PostgreSQL in Docker (xUnit, Alba and Testcontainers), and `tests/e2e`, which drives it in
Chrome (Playwright), including accessibility checks. The client's unit tests (Vitest) are always
there, next to the code. See [Testing](./testing.md).

Set it to `false` only if you'll write your own: the tests are also the best examples of how to test
a new feature.

## Aspire: `--Aspire` {#aspire}

With `true`, the app also has `src/ApiHost.AppHost`, an [Aspire](https://aspire.dev/) AppHost:
`dotnet run --project src/ApiHost.AppHost` starts PostgreSQL, Mailpit, the API and the dev server,
and opens a dashboard with their logs, traces and metrics. It's for development only; production is
unchanged. Without it, `docker compose up -d` and two terminals do the same
([run it](./overview.md#run-it), [with Aspire](./how-to/run-with-aspire.md)).

## The name people see: `--DisplayName` {#displayname}

`-n` must be a C# name, so `-n HairyNotes` would show "HairyNotes" everywhere people see the app's
name. `--DisplayName "Hairy Notes"` sets that name instead: page titles, the header and sidebar,
the link-preview tags, the name authenticator apps show (`Accounts:TwoFactorIssuer`)
and, in development, the email sender (`Email:Smtp:From`; set yours for production). In the code
it's `appName` in `src/Client/src/components/PageMeta.tsx`. Leave it out to use the `-n` name.

## After generating

* **Commit the app as generated,** before changing it. Upgrading to a later version of the template
  applies the template's changes as a patch, which works best when that first commit is in your
  history ([Upgrading](../upgrading/)).
* **Keep `.saas-starter.json`.** It records the template version, the app's name and the options
  you chose, so an upgrade needs only the version you want.
* **Run it:** [A generated app](./overview.md) shows how, and what's in it.
