在asp.net 5+中首先使用带有代码的EF6,如何存储带有3个小数点的十进制值?
即,我的字段必须能够存储272.724
目前,我有:
[DataType(DataType.Currency)]
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:c}")]
[DisplayName("Report Fee")]
public decimal ReportFee { get; set; }
我尝试添加:
[Column(TypeName = "decimal(18,3)")]
但是我得到了错误:
The store type 'decimal(18,3)' could not be found in the SqlServer provider manifest
答案 0 :(得分:1)
您可以尝试使用自定义约定。设置小数精度:
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Properties<decimal>().Configure(config => config.HasPrecision(18, 3));
}