EntityFramework学习笔记之Decimal精度控制

1 public class EFDbContext : DbContext
2 {
3    protected override void OnModelCreating(System.Data.Entity.DbModelBuilder modelBuilder)
4    {
5        modelBuilder.Entity().Property(object => object.property).HasPrecision(12, 10);
6 
7        base.OnModelCreating(modelBuilder);
8    }
9 }
1 public DecimalPropertyConfiguration HasPrecision(
2 byte precision,
3 byte scale )

This is to show how to configure the precision by overriding the DbContext.OnModelCreating() method.

You can check information about this on the page:http://stackoverflow.com/questions/3504660/entity-framework-code-first-decimal-precision-and-scale

转载于:https://www.cnblogs.com/super86/archive/2013/04/25/3042694.html

你可能感兴趣的:(EntityFramework学习笔记之Decimal精度控制)