Polymorphic mapping when some derived types have explicit mappings and others do not #4396
Replies: 3 comments 1 reply
-
A PR is welcome. |
Beta Was this translation helpful? Give feedback.
1 reply
-
Another workaround:
|
Beta Was this translation helpful? Give feedback.
0 replies
-
This discussion has been automatically locked since there has not been any recent activity after it was closed. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Source/destination types
Mapping configuration
Version: 13.0.1
Expected behavior
with context.Cars being a DbSet of Cars should not throw an error.
Actual behavior
an error is thrown:
No coercion operator is defined between types 'Car' and 'Motorcycle'
Steps to reproduce
Gist
This code works in Automapper 12. The issue seems to be caused by there being an explicit mapping for one of the Vehicle subclasses, but not the other. Adding an explicit map fixes the issue.
Removing the map from Motorcycle to MotorcycleDto also fixes the issue, allowing
to execute properly.
Beta Was this translation helpful? Give feedback.
All reactions