Stick this in your DB Context if you need to have EF recongise more than two decimal places.
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
// We have a Decimal Field in Our SQL Table decimal(18, 4)
// By default only the first two digits after the decimal will be recognised if this property is set to type decimal
// we need to override this behaviour and here's how
modelBuilder.Entity<MyObjec t>().Property(f => f.totalWeightMg).HasPrecision(18,4);
base.OnModelCreating(modelBuilder);
}
No comments:
Post a Comment