0

When applying a migration using "update-database" I get an error about conversion of datetime2 to datetime. How do I fix this?

Keith Harris
  • 1,118
  • 3
  • 13
  • 25

1 Answers1

0

Oh... I found the answer. You have to add the following line to the OnModelCreating method in your DbContext class:

modelBuilder.Properties<DateTime>().Configure(c => c.HasColumnType("datetime2"));
Keith Harris
  • 1,118
  • 3
  • 13
  • 25