Skip to content

Choosing a Provider

Every Domain Services module separates the service (business logic) from the repository (data access). You pick the repository that matches where your data lives. The service code doesn't change.


Decision guide

Question Answer Provider to use
Is this a demo, prototype, or local dev? Yes JSON file (JsonRepository) — zero infra, data is a plain .json file
Does your data already live in PostgreSQL? Yes PostgreSQL (DHI.Services.Provider.PostgreSQL)
Are you proxying an existing DS Web API? Yes DS (DHI.Services.Provider.DS)
Do you need DFS0/DFS2/DFSU file access? Yes MIKECore (DHI.Services.Provider.MIKECore)
Do you need MCLite / MIKE Cloud Lite storage? Yes MCLite (DHI.Services.Provider.MCLite)
Do you need live USGS water data (US only)? Yes USGS (DHI.Services.Provider.USGS)
Are you reading from MIKE Cloud? Yes MIKE Cloud (DHI.Services.Provider.MIKECloud)

Provider details

JSON (file-based)

Built into the core DHI.Services package — no extra install needed.

var repo = new JsonRepository<MySensor, Guid>("[AppData]sensors.json".Resolve());

Use when: local development, demos, small datasets that don't need a database.

Limitations: no concurrent writes, not suitable for production under load.


PostgreSQL

dotnet add package DHI.Services.Provider.PostgreSQL

The connection string goes in connections.json or an environment variable:

"ConnectionString": "[env:POSTGRES_CONN]"

Where POSTGRES_CONN = "Server=host;Port=5432;Database=db;User Id=user;Password=pass".

Use when: production deployments, shared data, concurrent access, durable storage.

Most domain modules (Scalars, TimeSeries, Jobs, GIS, etc.) have a PostgreSQL repository. Check the module's reference page to confirm support.


DS (Domain Services remote proxy)

dotnet add package DHI.Services.Provider.DS

Proxies calls to another DS Web API. The connection string is the base URL of the remote API.

Use when: you want to aggregate data from another DS deployment without ETL, or fan out to multiple instances.


MIKECore (DFS files)

dotnet add package DHI.Services.Provider.MIKECore

Reads DFS0, DFS2, DFSU, and mesh files. Requires the MIKE SDK assemblies to be present.

Use when: your data is in DHI's binary model file formats.


MCLite

dotnet add package DHI.Services.Provider.MCLite

Use when: you're working within the MIKE Cloud Lite platform.


USGS

dotnet add package DHI.Services.Provider.USGS

Reads time series from the USGS Water Services API (US gauge stations).

Use when: you need live or historical water data from USGS without maintaining your own ETL pipeline.


Running multiple providers side-by-side

A single Web API can serve multiple providers simultaneously — each with its own connectionId. For example, one API can expose JSON data under sensors-local and PostgreSQL data under sensors-prod:

{
  "$type": "System.Collections.Generic.Dictionary`2[[System.String, mscorlib],[DHI.Services.IConnection, DHI.Services]], mscorlib",
  "sensors-local": {
    "$type": "MyApp.SensorServiceConnection, MyApp",
    "RepositoryType": "MyApp.SensorRepository, MyApp",
    "ConnectionString": "[AppData]sensors.json",
    "Id": "sensors-local"
  },
  "sensors-prod": {
    "$type": "MyApp.SensorServiceConnection, MyApp",
    "RepositoryType": "DHI.Services.Provider.PostgreSQL.SensorRepository, DHI.Services.Provider.PostgreSQL",
    "ConnectionString": "[env:POSTGRES_CONN]",
    "Id": "sensors-prod"
  }
}

See Register Services Dynamically with connections.json for full setup.