Something weird is happening with:
using (var connection = new SqlConnection(ConnectionString))
{
var mappings = new List<BulkInsertMapItem>
{
new BulkInsertMapItem("TransactionID", "TransactionID"),
new BulkInsertMapItem("DateCreated", "DateCreated"),
};
mergedRows = await connection.BulkMergeAsync<Transaction>(data, mappings: mappings).ConfigureAwait(false);
}
The call to BulkMergeAsync fails because, according to RepoDB: "Column name 'ID' does not exist in the target table or view".
But the ID field (primary key, identity) is available in the Transaction class:
[Map("[dbo].[Transactions]")]
public class Transaction
{
[Primary, Identity, Map("ID")]
public long ID { get; set; }
public long TransactionID { get; set; }
public DateTime DateCreated { get; set; }
and in the database itself:

This exception was originally thrown at this call stack:
System.Data.SqlClient.SqlConnection.OnError(System.Data.SqlClient.SqlException, bool, System.Action<System.Action>)
System.Data.SqlClient.SqlInternalConnection.OnError(System.Data.SqlClient.SqlException, bool, System.Action<System.Action>)
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(System.Data.SqlClient.TdsParserStateObject, bool, bool)
System.Data.SqlClient.TdsParser.TryRun(System.Data.SqlClient.RunBehavior, System.Data.SqlClient.SqlCommand, System.Data.SqlClient.SqlDataReader, System.Data.SqlClient.BulkCopySimpleResultSet, System.Data.SqlClient.TdsParserStateObject, out bool)
System.Data.SqlClient.SqlCommand.InternalEndExecuteNonQuery(System.IAsyncResult, string, bool)
System.Data.SqlClient.SqlCommand.EndExecuteNonQueryInternal(System.IAsyncResult)
System.Data.SqlClient.SqlCommand.EndExecuteNonQueryAsync(System.IAsyncResult)
System.Threading.Tasks.TaskFactory.FromAsyncCoreLogic(System.IAsyncResult, System.Func<System.IAsyncResult, TResult>, System.Action<System.IAsyncResult>, System.Threading.Tasks.Task, bool) in FutureFactory.cs
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task) in TaskAwaiter.cs
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task) in TaskAwaiter.cs
...
[Call Stack Truncated]
Something weird is happening with:
The call to BulkMergeAsync fails because, according to RepoDB: "Column name 'ID' does not exist in the target table or view".
But the ID field (primary key, identity) is available in the Transaction class:
and in the database itself:

This exception was originally thrown at this call stack:
System.Data.SqlClient.SqlConnection.OnError(System.Data.SqlClient.SqlException, bool, System.Action<System.Action>)
System.Data.SqlClient.SqlInternalConnection.OnError(System.Data.SqlClient.SqlException, bool, System.Action<System.Action>)
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(System.Data.SqlClient.TdsParserStateObject, bool, bool)
System.Data.SqlClient.TdsParser.TryRun(System.Data.SqlClient.RunBehavior, System.Data.SqlClient.SqlCommand, System.Data.SqlClient.SqlDataReader, System.Data.SqlClient.BulkCopySimpleResultSet, System.Data.SqlClient.TdsParserStateObject, out bool)
System.Data.SqlClient.SqlCommand.InternalEndExecuteNonQuery(System.IAsyncResult, string, bool)
System.Data.SqlClient.SqlCommand.EndExecuteNonQueryInternal(System.IAsyncResult)
System.Data.SqlClient.SqlCommand.EndExecuteNonQueryAsync(System.IAsyncResult)
System.Threading.Tasks.TaskFactory.FromAsyncCoreLogic(System.IAsyncResult, System.Func<System.IAsyncResult, TResult>, System.Action<System.IAsyncResult>, System.Threading.Tasks.Task, bool) in FutureFactory.cs
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task) in TaskAwaiter.cs
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task) in TaskAwaiter.cs
...
[Call Stack Truncated]