Skip to content

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:

  1. Runs database migrations from the migration projects (e.g., IdentityServer.Migrations.Sqlite)
  2. Loads trust anchor certificates from the file system and configuration
  3. Creates trust communities based on directory structure
  4. Initializes default users with configured passwords

File-based Seeding

The server automatically discovers trust anchors from the CertStore directory:

Directory Structure

  • Each subdirectory in CertStore becomes a trust community
  • The directory name becomes the community name
  • All .cer and .crt files 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 .cer or .crt file
  • Base64 string - Base64-encoded certificate content