How do I specify decimal precision when creating a table column in Code First Entity Framework 4.2?
Asked
Active
Viewed 352 times
0
-
title and question text are very different and unrelated, aspnet and aspnet-mvc tags are missing... – Davide Piras Feb 08 '12 at 09:12
1 Answers
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);
}
}
Good luck!