.net core ef decimal 设置
decimal(18,0)的意思是:可储存的最大十进位数总数为18,小数位数为0。
2、Decimal(n,m)的含义如下:
n表示可储存的最大十进位数总数,小数点左右两侧都包括在内,最小的有效位数是 1 ,最大的有效位数是 38 。
m表示小数点右侧所能储存的最大十进位数。m和n之间要满足0≤m≤n的关系,只有在指定了有效位数时,才能指定小数位数。
sql语句 decimal(18,0)什么意思-百度经验 (baidu.com)
设置 HasPrecision 18 为 表示可储存的最大十进位数总数 3 为小数点位数
protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); //商品 modelBuilder.Entity<Product>(item => { item.HasKey(p => p.Id); item.Property(p => p.Price).HasColumnType("decimal").HasPrecision(18,3); }); //热备数据 modelBuilder.Entity<SparingProduct>(item => { item.HasKey(p => p.Id); }); }