✅ How to properly set a default value as UtcNow with EF Core and PostgreSQL
Hi there,
I use EF Core with a PostgreSQL DB. I want that each time I add an entity with EF Core in the DB, it saves the CreatedOn field with the value of the UtcNow. I tried this :
But when I do "Add-Migration", I see that EF Core just saves the UtcNow once and will give this same value for every entity that I add. If its 14h when I do the migration, every entity that I will add in the future will have this 14h value in the CreatedOn. It is not dynamic. And the NOW() PostgreSQL function like this doesn't give the UtcNow unfortunately :