在 EF6 中,我可以使用以下代码,以便我所有的日期都使用 datetime2(0) 作为列类型
modelBuilder.Properties<DateTime>()
.Configure(c => c
.HasColumnType("datetime2")
.HasPrecision(0));
我如何在 EFCore 中执行此操作??
最佳答案
您需要安装 Nuget 包:Microsoft.EntityFrameworkCore.SqlServer。安装后,您可以在您的属性中使用 HasColumnType("datetime")。 :)
关于c# - EFCore 2.0 默认所有日期字段使用 datetime2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44393108/