From 950089a113b86d63e8d9cf9139b6a364010c68a2 Mon Sep 17 00:00:00 2001 From: Christopher Jolly Date: Wed, 26 Apr 2023 23:49:24 +0800 Subject: [PATCH] Set the precision to be maximum of 28 (Jet limit). When using property.HasConversion() the default for EF Core is with precision 38 and scale 17 which is passed Jet's limit --- .../Storage/Internal/JetDecimalTypeMapping.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/EFCore.Jet/Storage/Internal/JetDecimalTypeMapping.cs b/src/EFCore.Jet/Storage/Internal/JetDecimalTypeMapping.cs index 5b313a6..12de982 100644 --- a/src/EFCore.Jet/Storage/Internal/JetDecimalTypeMapping.cs +++ b/src/EFCore.Jet/Storage/Internal/JetDecimalTypeMapping.cs @@ -53,7 +53,20 @@ namespace EntityFrameworkCore.Jet.Storage.Internal /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected override RelationalTypeMapping Clone(RelationalTypeMappingParameters parameters) - => new JetDecimalTypeMapping(parameters); + { + var precision = parameters.Precision; + var scale = parameters.Scale; + if (parameters.Precision is > 28) + { + int prec_diff = parameters.Precision.Value - 28; + precision = 28; + if (parameters.Scale is > 28) + { + scale = parameters.Scale.Value - prec_diff; + } + } + return new JetDecimalTypeMapping(parameters.WithPrecisionAndScale(precision, scale)); + } /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to