BulkInsertAll failling for table with no non primary key columns
JKorf opened this issue · comments
Hi, I'm trying to use your library, but BulkInsertAll gives me an SqlException: Invalid syntax near ','.
I tracked the problem down to this line: https://github.com/mtanneryd/ef6-bulk-operations/blob/7ca96c682037bad9c40de83c0041abe3f8ee5005/Tanneryd.BulkOperations.EF6/Tanneryd.BulkOperations.EF6/DbContextExtensions.cs#L1769
The issue is that 1 of my tables only has a primay key. It means that columnNames is an empty string, and it generates an sql statement like this:
MERGE [dbo].[TraitTargets]
USING
(SELECT , rowno
FROM tempdb..#9ada186c0c524a4aa88daa44962c87a4) t (, rowno)
ON 1 = 0
WHEN NOT MATCHED THEN
INSERT ()
VALUES ()
OUTPUT t.rowno,
inserted.[TraitTargetId];
which is indeed invalid sql. You should probably check if nonPrimaryKeyColumnMappings
has any values.
Any chance for a quick fix?
I believe this has been fixed. Please re-open if this is not so.