Entity Framework 中Decimal字段长度设置方法

在创建项目DbContext时,重写DbContext.OnModelCreating()方法;然后通过如下方法指定精度

1 protected override void OnModelCreating(DbModelBuilder modelBuilder) 
2 { 
3     modelBuilder.Entity<Product>().Property(product => product.Price).HasPrecision(18, 12); 
4 } 

posted on 2014-07-16 12:25  孜萧哲  阅读(938)  评论(0编辑  收藏  举报

导航