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 }
浙公网安备 33010602011771号