Db2

Db2

Connect with Db2, open source, and other data experts to gain value from your data, share insights, and solve problems.

 View Only
Expand all | Collapse all

Issue using decimal for key - IBM.EntityFrameworkCore 8.0.0.100

  • 1.  Issue using decimal for key - IBM.EntityFrameworkCore 8.0.0.100

    Posted Mon February 05, 2024 01:30 PM

    Hi,

    Using the new IBM.EntityFrameworkCore 8.0.0.100 package we get an exception thrown when using decimal as key for entity. Caused by IBM.EntityFrameworkCore.Internal.Db2Strings.LogDecimalTypeKey(IDiagnosticsLogger logger). 

    Value cannot be null. (Parameter 'format')'

       at System.ThrowHelper.Throw(String paramName)
       at Microsoft.Extensions.Logging.LogValuesFormatter..ctor(String format)
       at Microsoft.Extensions.Logging.LoggerMessage.CreateLogValuesFormatter(String formatString, Int32 expectedNamedParameterCount)
       at Microsoft.Extensions.Logging.LoggerMessage.Define[T1,T2](LogLevel logLevel, EventId eventId, String formatString, LogDefineOptions options)
       at Microsoft.Extensions.Logging.LoggerMessage.Define[T1,T2](LogLevel logLevel, EventId eventId, String formatString)
       at IBM.EntityFrameworkCore.Internal.Db2Strings.<>c.<LogDecimalTypeKey>b__21_1(LogLevel level)
       at Microsoft.EntityFrameworkCore.Diagnostics.EventDefinition`2..ctor(ILoggingOptions loggingOptions, EventId eventId, LogLevel level, String eventIdCode, Func`2 logActionFunc)
       at IBM.EntityFrameworkCore.Internal.Db2Strings.<>c__DisplayClass21_0.<LogDecimalTypeKey>b__0()
       at System.Threading.LazyInitializer.EnsureInitializedCore[T](T& target, Func`1 valueFactory)
       at IBM.EntityFrameworkCore.Internal.Db2Strings.LogDecimalTypeKey(IDiagnosticsLogger logger)
       at IBM.EntityFrameworkCore.Internal.Db2LoggerExtensions.DecimalTypeKeyWarning(IDiagnosticsLogger`1 diagnostics, IProperty property)
       at IBM.EntityFrameworkCore.Infrastructure.Internal.Db2ModelValidator.ValidateDecimalColumns(IModel model, IDiagnosticsLogger`1 logger)
     at IBM.EntityFrameworkCore.Infrastructure.Internal.Db2ModelValidator.Validate(IModel model, IDiagnosticsLogger`1 logger)



    ------------------------------
    Martin Lindström
    ------------------------------


  • 2.  RE: Issue using decimal for key - IBM.EntityFrameworkCore 8.0.0.100

    Posted Tue February 06, 2024 02:40 AM

    In our case we could resolve this temporarily using:

                .HasColumnType("decimal(2, 0)")
              .HasConversion<int>()



    ------------------------------
    Martin Lindström
    ------------------------------