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));
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With