When applying a migration using "update-database" I get an error about conversion of datetime2 to datetime. How do I fix this?
Asked
Active
Viewed 83 times
1 Answers
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