Skip to content

Migration from v9 to v10

Pawel Gerr edited this page Nov 21, 2025 · 2 revisions

Migration from v9 to v10

This guide covers breaking changes and new features when migrating from v9 to v10.

Entity Framework Core Configuration (BREAKING CHANGE)

v10 introduces a new, more structured configuration API for Entity Framework Core integration. The old callback-based approach is deprecated but still supported for backward compatibility.

What Changed

The UseThinktectureValueConverters method now accepts a Configuration object that provides:

  • Type-safe configuration for Smart Enums and Keyed Value Objects
  • Built-in max length strategies for automatic database column sizing
  • Better defaults with smart enum max length calculation out-of-the-box

Old API (v9 - Deprecated)

.UseThinktectureValueConverters(configureEnumsAndKeyedValueObjects: property =>
{
   if (property.ClrType == typeof(ProductType))
   {
      var maxLength = ProductType.Items.Max(i => i.Key.Length);
      property.SetMaxLength(maxLength + (10 - maxLength % 10)); // round up to next 10
   }
   else if (property.ClrType == typeof(ProductName))
   {
      property.SetMaxLength(200);
   }
})

New API (v10 - Recommended)

Option 1: Use default configuration (automatic max length for string-based smart enums)

.UseThinktectureValueConverters()
// or explicitly:
.UseThinktectureValueConverters(Configuration.Default)

Option 2: Custom configuration with strategies

.UseThinktectureValueConverters(new Configuration
{
   SmartEnums = new SmartEnumConfiguration
   {
      // Automatically calculates max length from items and rounds to next 10
      MaxLengthStrategy = DefaultSmartEnumMaxLengthStrategy.Instance
   },
   KeyedValueObjects = new KeyedValueObjectConfiguration
   {
      MaxLengthStrategy = new CustomKeyedValueObjectMaxLengthStrategy((type, keyType) =>
      {
         if (type == typeof(ProductName))
            return 200;

         return MaxLengthChange.None; // Max length stays unchanged
      })
   }
})

Clone this wiki locally