Skip to content

Commit

Permalink
docs: add database documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
EnisMulic committed Nov 11, 2023
1 parent bc493d7 commit 3a41089
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
27 changes: 26 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Configure the application using `appsettings.json`, `appsettings.Development.jso
dotnet user-secrets init --project src/Api
```

# Define Constants
### Define Constants

To test/develop the template with specific options add a `<DefineConstants>` block to `Directory.Build.props` file.

Expand All @@ -73,6 +73,31 @@ To start the app run:
dotnet run --project src/Api
```

## Database

The template uses MsSql migrations by default, so if you select PostgreSql as your database you will need to remove the `Application/Infrastructure/Persistance/Migrations` folder and create a new migration script.

When you run the application the database will be created (if it doesn't exist) and the migrations will be applied.

To run the migrations you will need to add the following flags to your ef commands.

* `-p | --project src/Application`
* `-s | --startup-project src/Api`
* `-o | --output-dir Infrastructure/Persistance/Migrations`

For example, to add a new migration:

```sh
dotnet ef migrations add \
-p src/Application \
-s src/Api \
-o Infrastructure/Persistance/Migrations "MigrationName"
```

```sh
dotnet ef migrations add -p src/Application -s src/Api -o Infrastructure/Persistance/Migrations "MigrationName"
```

## Auth

Generate a bearer token using [dotnet user-jwts](https://learn.microsoft.com/en-us/aspnet/core/security/authentication/jwt-authn?view=aspnetcore-7.0&tabs=windows) with optional roles and policies
Expand Down
24 changes: 24 additions & 0 deletions README.template.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,30 @@ To start the app run:
dotnet run --project src/Api
```

## Database

When you run the application the database will be created (if it doesn't exist) and the migrations will be applied.

To run the migrations you will need to add the following flags to your ef commands.

* `-p | --project src/Application`
* `-s | --startup-project src/Api`
* `-o | --output-dir Infrastructure/Persistance/Migrations`

For example, to add a new migration:

```sh
dotnet ef migrations add \
-p src/Application \
-s src/Api \
-o Infrastructure/Persistance/Migrations "MigrationName"
```

```sh
dotnet ef migrations add -p src/Application -s src/Api -o Infrastructure/Persistance/Migrations "MigrationName"
```


## Auth

Generate a bearer token using [dotnet user-jwts](https://learn.microsoft.com/en-us/aspnet/core/security/authentication/jwt-authn?view=aspnetcore-7.0&tabs=windows) with optional roles and policies
Expand Down

0 comments on commit 3a41089

Please sign in to comment.