In asp.net 5+ using EF6 with code first, how do I store a decimal value with 3 decimal points?
Ie, my field needs to be able to store 272.724
Currently I have:
[DataType(DataType.Currency)]
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:c}")]
[DisplayName("Report Fee")]
public decimal ReportFee { get; set; }
I've tried adding:
[Column(TypeName = "decimal(18,3)")]
But I get the error:
The store type 'decimal(18,3)' could not be found in the SqlServer provider manifest
You can try with Custom Conventions. To set decimal precision:
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Properties<decimal>().Configure(config => config.HasPrecision(18, 3));
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.