Open Timovzl opened 9 months ago
I am not sure if it is related but I am trying to set a Converter with DefaultMapping for my SaleType
value object to string
type. What I expect is is that EF Core will use this conversion for collection properties i.e. List<SaleType>
to save them as primitive collection.
configurationBuilder.DefaultTypeMapping<SaleType>().HasConversion<EnumValueObjectConverter<SaleType>>();
But I get this error:
The exception 'The 'List
' property 'Pricing.SaleTypes' could not be mapped because the database provider does not support this type
@ogix Please open a new issue and attach a small, runnable project or post a small, runnable code listing that reproduces what you are seeing so that we can investigate.
Where
ModelConfigurationBuilder.Properties<TProperty>().HaveConversion<TConverter>()
honors the converter including its mapping hints,ModelConfigurationBuilder.DefaultTypeMapping<TScalar>().HasConversion<TConverter>()
will use the converter but not its mapping hints.This can be an issue where the type matters outside the context of a property. For example, when custom struct is used in place of a decimal, EF writes a cast to
decimal(precision, scale)
into the query, such as when usingSum()
. A cast to decimal is there, indicating that EF is aware of the conversion, but the precision and scale default back to18,2
instead of what the mapping hint has configured.Minimal Repro
Query String
Expected Query String
Include provider and version information
EF Core version: Database provider: Microsoft.EntityFrameworkCore.SqlServer Target framework: .NET 8.0 Operating system: Windows 10 IDE: Visual Studio 2022 17.8.0