efcore icon indicating copy to clipboard operation
efcore copied to clipboard

Q: HasConversion Overloads and confusing behavior

Open mattbdc opened this issue 1 year ago • 1 comments

When defining a model in EF Core 8.0. .HasConversion on PropertyBuilder has many overloads.

These twos call do different things.:

builder.HasConversion(instanceOfValueComparer)

v.s.

builder.HasConversion((ValueConverter)null, instanceOfValueComparer)

contrary to first guesses perhaps, the first removes the default value converter, the second leaves it in place.

I am wondering if this is a bug, or just part of a very confusing design, neither the above communicate they would act differently. I wanted to define a custom value comparer but leave the default serialization converter in place, which took more than a coffee to figure out...

mattbdc avatar Feb 15 '24 00:02 mattbdc

Duplicate of #30139. It's an unfortunate design, but not one we believe would be worth the breaking change to existing apps to change at this point.

ajcvickers avatar Feb 15 '24 15:02 ajcvickers