mtanneryd / ef-bulk-operations

Bulk operations for Entity Framework 6
Apache License 2.0
80 stars 30 forks source link

Error when bulk updating/inserting to SQL Server Temporal Tables #28

Open Steven-FlexTechs opened 4 years ago

Steven-FlexTechs commented 4 years ago

(Reference for Temporal Tables: https://docs.microsoft.com/en-us/sql/relational-databases/tables/creating-a-system-versioned-temporal-table?view=sql-server-ver15)

I utilize SQL Server Temporal Tables and my time columns have unique names different than the default SysStartTime and SysEndTime.

The error occurs when trying to update or insert to these columns which is not allowed. 2019-12-31 08_34_27-Window

I believe the solution would be to support configuring column names that need to be ignored in the "BulkUpdateAll" and "BulkInsertAll" methods.

I've been utilizing the solution below to support SQL Server Temporal Tables in EF for years. https://stackoverflow.com/questions/40742142/entity-framework-not-working-with-temporal-table

mtanneryd commented 4 years ago

Thanks for the feedback, much appreciated.

For BulkUpdateAll you can make it work as it is now even though it will be the other way around. Using the update method that takes a BulkUpdateRequest you can specify the columns you want to update. For BulkInsertAll I need to make some changes though and maybe I should add an "ignore-columns-property in the BulkUpdateRequest class.

I'll try to get a fix out as soon as possible. Currently also working on a multi target version that also supports .net core (not EF Core though that will have to wait a bit)