-
Notifications
You must be signed in to change notification settings - Fork 314
Description
Describe the bug
As the title describes, Hidden columns are always ignored by SqlBulkCopy, even when they are targets in SqlBulkCopy.ColumnMappings.
ColumnMapping does not exist in destination...
To reproduce
I will create a repro of this in my fork, but wanted to log this first and get some feedback if this would be a candidate to even be fixed because the behavior is so long-standing.
Expected behavior
Hidden columns should be accounted for when they are explicitly requested
Further technical details
Microsoft.Data.SqlClient version: 5.0.1
.NET target: net6
SQL Server version: SQL Server 2019
Operating system: Windows 10
Additional context
It seems like this behavior has always been there, so maybe this is a feature request (it seems like a bug at first glance to me though)
We have tables that are dynamically temporal -- users can choose to turn on / off temporal tables for their own databases. When they turn off, we only DROP PERIOD FOR SYSTEM_TIME so the columns are still there if they flip it back on. However, the columns remain hidden.
We can theoretically make the column not hidden with ALTER TABLE ALTER COLUMN DROP HIDDEN as a workaround, but I still think this is a potential bug.