1

So the problem is that I can't set the model so that the migration will show DateTimeKind.Utc instead of DateTimeKind.Unspecified I'm doing this:

contactsConfiguration
   .Property(c => c.DateAdded)
   .ValueGeneratedOnAdd()
   .HasConversion(v => v, v => DateTime.SpecifyKind(v, DateTimeKind.Utc))

Any ideas?

Henrik Wilshusen
  • 301
  • 1
  • 11
Marek M.
  • 4,010
  • 8
  • 39
  • 87
  • I had the same problem and used https://stackoverflow.com/a/19301623/3937941 Hope it helps. – Zysce Aug 10 '18 at 13:32
  • 1
    If you care about offsets use `DateTimeOffset` as a property and database field type, not `DateTime` with an *assumed* UTC value. `datetime` in the database has *no* indication that it's UTC or local (local to whom?). – Panagiotis Kanavos Aug 10 '18 at 13:58
  • BTW that migration has no meaning precisely because the `datetime` database type has no DateTimeKind. – Panagiotis Kanavos Aug 10 '18 at 14:01

0 Answers0