How to reproduce:
1) implment IDataReader without inherting from DbDataReader
2) Create a SqlBulkCopy object having a column mapping where from and to are column names.
3) WriteToServer will fail due to a null reference exception.
```c#
//how to repro. (Using DataBoss.Data 0.0.42 from NuGet on netstandard 2.0)
using DataBoss.Data;
using System;
using System.Data.SqlClient;
using System.Diagnostics;
namespace ConsoleApp3
{
class Program
{
static void Main(string[] args)
{
var db = new SqlConnection("Server=.;Integrated Security=SSPI");
db.Open();
db.ExecuteNonQuery("create table #Temp(id int not null)");
var toInsert = SequenceDataReader.Create(new[] { 1, 2, 3 }, x => x.Map("id", id => id));
var bulkCopy = new SqlBulkCopy(db)
{
DestinationTableName = "#Temp",
};
for (var i = 0; i != toInsert.FieldCount; ++i)
{
var n = toInsert.GetName(i);
bulkCopy.ColumnMappings.Add(n, n);
}
bulkCopy.WriteToServer(toInsert);
}
}
}
```
Known workaround: Create the column mapping by ordinal (change bulkCopy.ColumnMappings.Add(n, n); to 2.Add(i, n)".
Likely culprit as far as I can discern is mishandling the _DbDataReaderSource here:

[EDIT] Add C# syntax highlight + space formatting by @karelz
[EDIT] Clarified repro code, added link to my guess on source. @drunkcod
@drunkcod where is the code snippet from? Can you please just link it instead of screenshot? (I couldn't find it in CoreFX)
Clarified that the snippet is for reproduction (and what packages to includede) and linked to the screnshotted line (sorry didn't know one could do that before)
https://github.com/dotnet/corefx/blob/master/src/System.Data.SqlClient/src/System/Data/SqlClient/SqlBulkCopy.cs#L848
Hello
This is (very probably) duplicate of dotnet/runtime#23843, and the fix was already mreged dotnet/corefx#24655.
@drunkcod As a workaround for now, you have to inherit from DbDataReader.
Hmmmm... On the second look, it seems, that it is the same issue, but another place, so another fix is needed. I will try to reproduce it and preprare PR in couple of days.
@satano - duplicate looks legit!
My "likely culprit" is from reading the code hunting for a non null-checked access so if it doesn't repro on current dev-bits you can likely assume it's my code reading that's at fault and the issue will disappear whenever the those bits are trickled out to nuget.
Since it works if I use "ordinal to name" instead of "name to name" column mappings and my use-case will work wonderfully well with that I'll simply go with that. One could argue that's a more elegant way anyhow.
Thanks for the swift responses and sorry for the missing link and bad search-fu in the issue tracker.
Duplicate of dotnet/runtime#23843
Thanks for detecting the dupe @satano!
Most helpful comment
Hello
This is (very probably) duplicate of dotnet/runtime#23843, and the fix was already mreged dotnet/corefx#24655.
@drunkcod As a workaround for now, you have to inherit from
DbDataReader.