0

How do I specify decimal precision when creating a table column in Code First Entity Framework 4.2?

lexeme
  • 2,915
  • 10
  • 60
  • 125
user473104
  • 301
  • 2
  • 6
  • 17

1 Answers1

1

Try using this approach http://geekswithblogs.net/danemorgridge/archive/2010/12/20/ef4-code-first-control-unicode-and-decimal-precision-scale-with.aspx

or

The simplier one:

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);
    }
}

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

Good luck!

Community
  • 1
  • 1
lexeme
  • 2,915
  • 10
  • 60
  • 125