entityframework core and sql 2016 temporal tables

.net-core asp.net-core c# entity-framework-core temporal-tables

Question

we are using efcore and sql 2016 for our .net core web api. I am evaluating use of temporal tables and its impact on efcore code. when i generate the ef model using cmd line then it generates model with appstart,append and mappings in dbcontext. when i do insert/update they fail saying these columns cannot be updated. I had to remove appstart,end from model and dbcontext mapping to make it work. I read there is no interception capbility yet in efcore like ef6.x. please advise better solution for this.

1
5
12/31/2018 11:41:29 AM

Accepted Answer

I tried below options and they are working.

  1. option 1: removed appstart, append fields from entities and dbcontext mappings and updates/insert started working properly.

  2. option 2: decorate period columns with attributes as below.


[DatabaseGenerated(DatabaseGeneratedOption.Computed)]
public DateTime StartTime { get; set; }

[DatabaseGenerated(DatabaseGeneratedOption.Computed)]
public DateTime EndTime { get; set; } 
5
12/27/2018 4:22:33 AM

Popular Answer

There currently is no better solution for this, and the feature is on the backlog.



Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow