Reputation: 2879
I want to use TimescaleDB on a specific table containing time-series data. The question I have is how to setup time-series from entity framework core and make a specific table a hyper table?
Database: Postgress version 11 Framework: Ef Core 2.2 Method: Code First
Upvotes: 3
Views: 3600
Reputation: 2879
This is the solution for code-first EF. It is pretty straight forward.
1) Add one date-time field in your model of the table you want to scale with timescale db.
2) Install the timescale plugin for Postgres.
CREATE EXTENSION timescaledb;
3) Execute the following SQL in a database seeder or initializer.
dbcontext.Database.ExecuteSqlCommand("SELECT create_hypertable('table_name', 'datetime_field_name');");
(datetime_field_name
is a required datetime field for timescale db (see 1))
Upvotes: 6