CmdScale.EntityFrameworkCore.TimescaleDB (aka Eftdb) is an EntityFrameworkCore provider for TimescaleDB. It lets you interact with TimescaleDB in a type-safe way with rich IntelliSense support, so you don't have to write SQL in magic strings like you did with plain Npgsql - all without losing a single feature of Npgsql.
Tip
Learn more about Eftdb in the documentation
For a typical project, install both packages:
dotnet add package CmdScale.EntityFrameworkCore.TimescaleDB
dotnet add package CmdScale.EntityFrameworkCore.TimescaleDB.Design| Package | Description |
|---|---|
CmdScale.EntityFrameworkCore.TimescaleDB |
Runtime support for EF Core + TimescaleDB |
CmdScale.EntityFrameworkCore.TimescaleDB.Design |
Design-time support for EF Core tooling (dotnet ef migrations and scaffolding) |
Tip
You do NOT have to install Npgsql.EntityFrameworkCore.PostgreSQL — it is referenced transitively via CmdScale.EntityFrameworkCore.TimescaleDB.
Chain .UseTimescaleDb() after .UseNpgsql() when configuring your DbContext. This registers all components that make EF Core aware of TimescaleDB's features.
string? connectionString = builder.Configuration.GetConnectionString("Timescale");
builder.Services.AddDbContext<TimescaleContext>(options =>
options.UseNpgsql(connectionString).UseTimescaleDb());You can either use the Fluent API or Data Annotations.
Fluent API
public class WeatherData
{
public Guid Id { get; set; }
public DateTime Time { get; set; }
public double Temperature { get; set; }
public double Humidity { get; set; }
}
public class WeatherDataConfiguration : IEntityTypeConfiguration<WeatherData>
{
public void Configure(EntityTypeBuilder<WeatherData> builder)
{
builder.HasKey(x => new { x.Id, x.Time });
builder.IsHypertable(x => x.Time)
.WithChunkTimeInterval("7 days");
}
}Data Annotations
[Hypertable(nameof(Time), ChunkTimeInterval = "7 days")]
[PrimaryKey(nameof(Id), nameof(Time))]
public class WeatherData
{
public Guid Id { get; set; }
public DateTime Time { get; set; }
public double Temperature { get; set; }
public double Humidity { get; set; }
}With the Design package installed, you can generate the migration with the default dotnet ef tools, just like you're used to.
dotnet ef migrations add "AddWeatherData"
dotnet ef database updateEftdb targets the latest .NET LTS release. Support follows a rolling two-version model:
| Support Level | Scope |
|---|---|
| Current LTS | New features and bug fixes |
| Previous LTS | Critical bug fixes only |
Example: When .NET 12 (LTS) releases, it becomes the development target. .NET 10 receives only critical fixes, and .NET 8 support ends.
This policy balances maintainability with ensuring the most widely-used .NET versions receive support.
If you have questions, ideas, or need help getting started, feel free to open an issue. We’re happy to help and discuss!
Thank you for contributing! 💜