Error occurs when working with table which has an identification
column. Insert method is executed well for tables without an id.
At SqlDataProviderBase.cs at code:
foreach (var memberMapper in members)
bc.ColumnMappings.Add(new
SqlBulkCopyColumnMapping(memberMapper.Ordinal, memberMapper.Name));
"SqlBulkCopyColumnMapping" gets "memberMapper.Ordinal", but if you
have an id column in your table as first column, the first
"memberMapper.Ordinal" value will be 1, next will be 2 and etc.
So, when "WriteToServer" is executing, it calls "object GetValue(int
i)" method, which accesses to the "_members" array. This array
contains n - 1 elements, where "n - 1" - the number of columns in the
table without id. But the value of variable i in the "object
GetValue(int i)" method complies to the value "memberMapper.Ordinal".
The last value of "memberMapper.Ordinal" is "n". But "_members" array
contains "n - 1" elements. It occurs an error.