Document Db

Description

Document stores register through IFlexDocumentStore<TDocument> (and IFlexDocumentStore for multi-collection scenarios). Your application code stays provider-agnostic while Cosmos DB, DynamoDB, MongoDB, and RavenDB handle persistence.

Configuration in DI

Register only the provider store(s) you need.

// Pick ONE provider and register the document types you use.
services.AddFlexCosmosDocumentStore<CustomerProfile>(configuration);
// services.AddFlexMongoDocumentStore<CustomerProfile>(configuration);
// services.AddFlexDynamoDocumentStore<CustomerProfile>(configuration);
// services.AddFlexRavenDocumentStore<CustomerProfile>(configuration);

appsettings.json

Document DB configuration is read from FlexBase:DataStores:Document:<Provider>.

{
  "FlexBase": {
    "DataStores": {
      "Document": {
        "CosmosDb": {
          "Endpoint": "https://...",
          "AccountKey": "<store-in-secrets>",
          "DatabaseName": "{YourApplication}",
          "ContainerName": "CustomerProfiles"
        }
      }
    }
  }
}

Sample usage ({YourApplication})

Provider pages

  • Cosmos DB: document-db/cosmos-db.md

  • DynamoDB: document-db/dynamo-db.md

  • MongoDB: document-db/mongo-db.md

  • RavenDB: document-db/raven-db.md

Provider considerations

  • Keep secrets (keys/connection strings) out of source control.

  • For Cosmos DB, set partition keys consistently with your model and access patterns.

Last updated