I am trying to run Hangfire with SQL Server 2005 which does not have datetime2 data type so I found this discussion very helpful. Unfortunately, while that fixes one problem it led immediately into another. Now I get the error: SqlMapper.cs not found. An exception of type ‘System.Data.SqlClient.SqlException’ occurred in System.Data.dll but was not handled in user code. Incorrect syntax near ‘merge’.
I found some information about the Dapper.1.38 package regarding SqlMapper.cs and obtained the code from GitHub but I get a message that the source file is different from when the module was built. It is frustrating trying to get this to work.
I’ve done more digging and found the SQL command that is causing the exception. It is this:
merge HangFire.Server as Target
using (VALUES (@id, @data, @heartbeat)) as Source (Id, Data, Heartbeat)
on Target.Id = Source.Id
when matched then
update set Data = Source.Data, LastHeartbeat = Source.Heartbeat
when not matched then
insert (Id, Data, LastHeartbeat) values (Source.Id, Source.Data, Source.Heartbeat);
I have never used the merge command before so it will take me some time to figure out what it is trying to accomplish and whether the syntax is not compatible with SQL Server 2005. Any help would be appreciated.