Skip to content

Latest commit

 

History

History
61 lines (45 loc) · 2.7 KB

README.md

File metadata and controls

61 lines (45 loc) · 2.7 KB

StartSCH

Development

Configuration

Push notifications (optional)

Some push services might require that the server identifies itself with a VAPID key pair. It is required by Apple. Keys can be generated here.

dotnet user-secrets set Push__PublicKey "..."
dotnet user-secrets set Push__PrivateKey "..."
dotnet user-secrets set Push__Subject "mailto:..."

Database

Migrations

After modifying the Db, you have to create new migrations:

dotnet tool install dotnet-ef --global

# Go to the server project directory (StartSch/StartSch)
cd StartSch

# Describe the migration
export MIGRATION_MESSAGE=AddSomethingToSomeOtherThing

# Add migration
dotnet ef migrations add --context SqliteDb $MIGRATION_MESSAGE
dotnet ef migrations add --context PostgresDb $MIGRATION_MESSAGE

# Remove latest migration
dotnet ef migrations remove --context SqliteDb
dotnet ef migrations remove --context PostgresDb

# Reset migrations
rm -r Data/Migrations
dotnet ef migrations add --context SqliteDb --output-dir Data/Migrations/Sqlite $MIGRATION_MESSAGE
dotnet ef migrations add --context PostgresDb --output-dir Data/Migrations/Postgres $MIGRATION_MESSAGE

Migrations are applied automatically on server startup.

Injecting a Db instance

Depending on where you want to access the database, you have to decide between injecting Db or IDbContextFactory<Db>.

For example, static forms or API controllers that run in a scope should use Db, while methods in an interactive Blazor component should request a new Db instance every time they run.