Gil*_*rdo 7 .net c# entity-framework entity-framework-core asp.net-core
在 EF6 中,我可以使用以下代码,以便我的所有日期都使用 datetime2(0) 作为列类型
modelBuilder.Properties<DateTime>()
.Configure(c => c
.HasColumnType("datetime2")
.HasPrecision(0));
Run Code Online (Sandbox Code Playgroud)
我怎样才能在 EFCore 中做到这一点?
您需要安装Nuget包:Microsoft.EntityFrameworkCore.SqlServer。安装后,您可以在属性中使用 HasColumnType("datetime") 。:)
| 归档时间: |
|
| 查看次数: |
6568 次 |
| 最近记录: |