The problem is that you are telling Dapper to wait for the sequence int, but in fact you have the possibility of meaning null. Therefore you need to either change the type
var x = connection.Query<int?>("SELECT max(val) FROM info").Single() ?? 0;
null.
var x = connection.Query<int>("SELECT COALESCE(max(val), 0) FROM info").Single();
Single , .
FirstOrDefault, , , .