Configuring precision after changing the column type is a NOOP:
modelBuilder
.Entity<Order>()
.Property(e => e.Date)
.HasColumnType("datetime2")
.HasPrecision(6)
***Original repro:
The convention below should set the default precision for all datetime objects in the model to 6 but currently it is a NOP. The other overload is .HasPrecision(byte, byte) and using this instead has the same behavior.
Convention:
modelBuilder.Properties<DateTime>()
.Configure(c => c
.HasPrecision(6));
Comments: The precision is set in the configuration, but it isn't applied to the model. It looks like when the PrimitiveType is changed from datetime to datetime2 for the EdmProperty representing the column the precision facet description isn't updated to be non-constant so the configuration is ignored.
modelBuilder
.Entity<Order>()
.Property(e => e.Date)
.HasColumnType("datetime2")
.HasPrecision(6)
***Original repro:
The convention below should set the default precision for all datetime objects in the model to 6 but currently it is a NOP. The other overload is .HasPrecision(byte, byte) and using this instead has the same behavior.
Convention:
modelBuilder.Properties<DateTime>()
.Configure(c => c
.HasPrecision(6));
Comments: The precision is set in the configuration, but it isn't applied to the model. It looks like when the PrimitiveType is changed from datetime to datetime2 for the EdmProperty representing the column the precision facet description isn't updated to be non-constant so the configuration is ignored.