.Net Entity Framework Core 设置浮点数精度

.Net Entity Framework core搭建框架,需要配置浮点数的精度,发现.Net Entity Framework core 并没有HasPrecision方法。

可以用HasColumnType配置浮点数精度。

对比.Net Entity Framework 和.Net Entity Framework Core 配置:

.Net Entity Framework 方法:
//配置订单的金额浮点数精度为decimal(18,6)
modelBuilder.Entity<Order>().Property(t => t.Amount).HasPrecision(18, 6);   

.Net Entity Framework Core方法:

//配置订单的金额浮点数精度为decimal(18,6)
modelBuilder.Entity<Order>().Property(p => p.Amount).HasColumnType("decimal(18,6)");

猜你喜欢

转载自blog.csdn.net/Teemo_2016/article/details/82381252
今日推荐