79648002

Date: 2025-06-01 22:56:38
Score: 1
Natty:
Report link

Answer / Workaround I Found
EF doesn’t enforce precision for computed columns unless you explicitly cast the result inside the SQL string:

.HasComputedColumnSql("CAST(([Price] * ([DurationInMinutes] / 60.0)) AS DECIMAL(18, 2))")

The .HasPrecision(...) method only affects non-computed columns unless your computed expression already returns the expected precision. EF doesn’t auto-wrap or warn you — so you have to handle that casting yourself.

Reasons:
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: MiddleEasternG