EF Core 6 十进制精度警告
EF Core 6 Decimal precision warning
升级到 EF Core 6 后,我在添加迁移时收到这个烦人的警告:
No store type was specified for the decimal property '{property}' on entity type '{entityType}'. This will cause values to be silently truncated if they do not fit in the default precision and scale. Explicitly specify the SQL server column type that can accommodate all the values in 'OnModelCreating' using 'HasColumnType', specify precision and scale using 'HasPrecision', or configure a value converter using 'HasConversion'.
我不确定是否理解此警告的目的,因为带有标签 [Keyless]
的实体并不存在于数据库中。另外添加诸如 [Column(TypeName = "decimal(28, 6)")]
之类的属性似乎无法清除无键实体上的警告。
显然有一个 new attribute for EF Core 6:
using Microsoft.EntityFrameworkCore;
...
[Precision(18, 2)]
升级到 EF Core 6 后,我在添加迁移时收到这个烦人的警告:
No store type was specified for the decimal property '{property}' on entity type '{entityType}'. This will cause values to be silently truncated if they do not fit in the default precision and scale. Explicitly specify the SQL server column type that can accommodate all the values in 'OnModelCreating' using 'HasColumnType', specify precision and scale using 'HasPrecision', or configure a value converter using 'HasConversion'.
我不确定是否理解此警告的目的,因为带有标签 [Keyless]
的实体并不存在于数据库中。另外添加诸如 [Column(TypeName = "decimal(28, 6)")]
之类的属性似乎无法清除无键实体上的警告。
显然有一个 new attribute for EF Core 6:
using Microsoft.EntityFrameworkCore;
...
[Precision(18, 2)]