Closed codyspeck closed 5 years ago
Hello @codyspeck ,
It works as expected.
Anything with the prefix AutoMap
only are taken if there is no mapping. In other words, the auto mapping only happens if there is no mapping.
If you specify the mapping, you should be able to specify that the column is also a key
bulk.ColumnMappings = new List<ColumnMapping>
{
new ColumnMapping("Name", "Name", true)
};
Let me know if that explains correctly why this behavior is not a bug but something working as intended.
Best Regards,
Jonathan
Ah, that works perfectly. Thank you for clearing that up for me!
Given the following table in SQL Server:
The following code throws an error:
"System.Exception: 'An error occured, no primary key could be found or resolved.'"
If the
ColumnMapping
s aren't set, then this code works fine. TheColumnMapping
is not needed for this example, but they are for my actual use case.Is there anything I can do to get around this or is this a bug?