AutoMapper / AutoMapper.Collection

AutoMapper support for updating existing collections by equivalency
MIT License
245 stars 59 forks source link

Updating to AutoMapper 10.0.0 causes exceptions #144

Closed slubowsky closed 4 years ago

slubowsky commented 4 years ago

See https://github.com/AutoMapper/AutoMapper.Collection.EFCore/issues/34, but seeing that Collections.EFCore depends on this project, I suspect issue actually belongs here especially as exact same thing happened when updating from AutoMapper 6 to 7 before the EFCore version existed. Looks like https://github.com/AutoMapper/AutoMapper/blob/master/docs/10.0-Upgrade-Guide.md#contextmappermap-overloads-that-receive-a-context-were-removed is the issue

amerkarim commented 4 years ago

I'm facing the same issue:

AutoMapper 10.0.0
AutoMapper.Collection 6.0.0

Adding or removing the .EntityFrameworkCore package has no effect.

The exception appears if you use the EqualityComparison method inside the profile.

This is the exception:

MissingMethodException: Method not found: 'System.__Canon AutoMapper.IRuntimeMapper.Map(System.__Canon, System.__Canon, AutoMapper.ResolutionContext, AutoMapper.IMemberMap)'.

AutoMapper.Mappers.EquivalentExpressionAddRemoveCollectionMapper.Map<TSource, TSourceItem, TDestination, TDestinationItem>(TSource source, TDestination destination, ResolutionContext context, IEquivalentComparer equivalentComparer)
AutoMapperMappingException: Error mapping types.

Mapping types:
Order -> Order
ViewModel.Order -> DomainModel.Order

Type Map configuration:
Order -> Order
ViewModel.Order -> DomainModel.Order

Destination Member:
OrderDetails

lambda_method(Closure , Order , Order , ResolutionContext )
Tasteful commented 4 years ago

The AM.Collection is not updated to support AM version 10 with the introduced breaking changes in that packages.

We accept PR's and until an update version is out you have to downgrade AM to a version that works with AM.Collection.

jbogard commented 4 years ago

This is to be expected, you're updating to a major version with breaking changes. In the future, we'll tag the package to only include the major version it supports.

slubowsky commented 4 years ago

Created PR. Thanks for the great work! (really looking forward to https://github.com/AutoMapper/AutoMapper/pull/3349 Currently I have ugly workarounds in place) You might also consider explaining somewhere that the different packages are not expected to be in sync. My expectation as someone unfamiliar with the inner workings here was that all the related libraries would be expected to be kept in sync.

jbogard commented 4 years ago

I think the version ranges should fix that though - NuGet will straight up error out and won't let you upgrade. We try to upgrade the libraries all together but it takes a little time.