I'm using PostgreSQL as relational database for my EF Core 6 project and I can not figure out how to get temporal tables to work with PostgreSQL after running migration. It works fine if I used SQL Server for it, but I would like to make it work in PostgreSQL.
Provider I use for EFCore: https://www.npgsql.org/efcore/
I follow this guide for temporal tables for EF Core 6 https://devblogs.microsoft.com/dotnet/prime-your-flux-capacitor-sql-server-temporal-tables-in-ef-core-6-0/
All tables have been created, but not the temporal tables / System-Versioned.
Code:
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => optionsBuilder.UseNpgsql("Host=my_host;Database=my_db;Username=my_user;Password=my_pw");}
Temporal tables using modelbuilder
modelBuilder.Entity<Car>().ToTable("Car", c => c.IsTemporal());
Is there anything I forgot? It also does not look like a temporal table is created in the migration / model snapshot itself
CodePudding user response:
I don't think PostgreSQL supports temporal tables out of the box but the functionality can be enabled using an extension and this might allow you to achieve creating the tables with EF Core.
The extension code can be found here: https://github.com/arkhipov/temporal_tables