There’s a much easier solution now in a similar question, but it is about string
.
For DateTime
:
SqlMapper.AddTypeMap(typeof(DateTime), System.Data.DbType.DateTime2);
This must be applied before any database call like INSERT
.
You can put it in your Main
or Startup
class, or any place that runs on Startup
to configure data access. SqlMapper
is a static
class and changes apply to all calls.