We are having issues using Entity Framework Core 2.2 with SQL Server temporal SystemVersioningTables.
The following resolve issues with Entity Framework and system versioning columns. entityframework core and sql 2016 temporal tables
Using the solution, is there a way for Entity Framework Core 2.2 to automatically add DatabaseGeneratedOption.Computed
or OnModelCreating
on SystemVersioning columns?
Is there a command parameter in dotnet ef dbcontext scaffold
?
We are seeking a way to automatically add this in, during automatic database scaffolding. This way, we don't have to manually add this in for all our 1000+ tables, or anytime we add new ones.
Company has many databases.
[DatabaseGenerated(DatabaseGeneratedOption.Computed)]
or
public partial class DatabaseDBContext : DbContext
{
partial void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Table1>(entity =>
{
entity.Property(e => e.StartTime)
.ValueGeneratedOnAddOrUpdate();
entity.Property(e => e.EndTime)
.ValueGeneratedOnAddOrUpdate();
});
}
}
We're using .NET Core 2.2.
Note: we do not want to hide the SQL Server columns, given as third solution in article.