mvc4 - db.SaveChanges() - decimal value out of range

社会主义新天地 提交于 2019-12-05 18:46:49
Mike Wallace

Found what the deal is between these two threads:

How do I prevent decimal values from being truncated to 2 places on save using the EntityFramework 4.1 CodeFirst?

Decimal precision and scale in EF Code First

Specifically applying this code to mine:

public class MyContext : DbContext
{
    public DbSet<Metrics> Metrics { get; set; }

    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
        modelBuilder.Entity<Metrics>().Property(x => x.PPM).HasPrecision(4, 3);
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!