Seeding Data
Data seeding allows you to initialize the database with trust anchors, communities, and other essential data when the server starts. This is enabled by default in the provided local configuration.
Enable Seeding
Set AppConfig__SeedData to true to enable automatic data seeding on server startup.
What Gets Seeded
When seeding is enabled, the server performs the following operations:
- Runs database migrations from the migration projects (e.g.,
IdentityServer.Migrations.Sqlite) - Loads trust anchor certificates from the file system and configuration
- Creates trust communities based on directory structure
- Initializes default users with configured passwords
File-based Seeding
The server automatically discovers trust anchors from the CertStore directory:
Directory Structure
- Each subdirectory in
CertStorebecomes a trust community - The directory name becomes the community name
- All
.cerand.crtfiles in the directory are added as trust anchors
Default structure:
CertStore/
├── EmrDirect/
│ └── EmrDirectTestCA.crt
├── LocalCA/
│ ├── LocalCA.crt
│ └── intermediates/
│ └── LocalSubCA.crt
├── FastCA/
│ ├── FastCA.crt
│ └── intermediates/
│ └── FastSubCA.crt
└── SureFhirLabs/
└── SureFhirLabs.crt
Configuration-based Seeding
You can also seed anchors through configuration using the AppConfig__Anchors setting:
appsettings.json
{
"AppConfig": {
"SeedData": true,
"Anchors": [
{
"AnchorFile": "/path/to/anchor.crt",
"Community": "MyTrustCommunity1"
},
{
"AnchorFile": "base64 encoded string of anchorfile",
"Community": "MyTrustCommunity2"
}
]
}
}
Anchor File Formats
The AnchorFile property accepts:
- File path - Absolute or relative path to a
.ceror.crtfile - Base64 string - Base64-encoded certificate content