Skip to content
This repository has been archived by the owner on Apr 19, 2023. It is now read-only.

1.5.* fails with Dapper multi mapping where 1.4.1 works #42

Closed
cpisto opened this issue Aug 9, 2016 · 4 comments
Closed

1.5.* fails with Dapper multi mapping where 1.4.1 works #42

cpisto opened this issue Aug 9, 2016 · 4 comments
Labels
Milestone

Comments

@cpisto
Copy link

cpisto commented Aug 9, 2016

On .net 4.5.2 (Dapper 1.50.2), Dapper.FluentMap 1.5.0 and 1.5.1 using the PropertyTransformConvention from the readme applied via:

FluentMapper.Initialize(config =>
{
    config.AddConvention<PropertyTransformConvention>()
          .ForEntitiesInCurrentAssembly("App.Domain.Models")
}

in conjunction with Dapper multi mapping throws an exception:

Finding mappings for column 'id' yielded more than 1 PropertyMap. The conventions should be more specific.

Works perfectly with 1.4.1 and below.

@henkmollema
Copy link
Owner

That's odd. Nothing should have changed there. Does your entity and database table still looks the same?

@cpisto
Copy link
Author

cpisto commented Aug 16, 2016

Yes everything is the same, swapping 1.5.* for 1.4.1 fixes the issue.

In my example, both tables have an id column, however only one of the entities being multi-mapped has a matching Id property.

I will try to find time to build a specific test case later this week.

@bengavin
Copy link

bengavin commented Dec 14, 2016

We are seeing a similar issue when moving to 1.5.1 from 1.4.x, in our case, it seems to be directly related to inheritance hierarchies. When we register a global property prefix, we're seeing the duplicate property map error showing up. Commenting out the ForEntity<> for the derived classes (or base class) makes the problem go away, but prevents the conventions from apply to those excluded entities.

Based on the test project, although I've been unable to get it to fail at this point (haven't had time to figure out what code path Dapper is using), but setting up the mapping to look like:

FluentMapper.Initialize(c => 
{
   c.AddConvention<TestPrefixConvention>()
       .ForEntity<TestEntity>()
       .ForEntity<DerivedTestEntity>();
});

edit: use syntax highlighting

@henkmollema henkmollema mentioned this issue Aug 22, 2017
3 tasks
@henkmollema henkmollema modified the milestone: v2.0 Aug 22, 2017
@henkmollema henkmollema modified the milestones: v2.0, v1.7.0 Nov 16, 2018
@henkmollema
Copy link
Owner

This have been fixed for applications targeting full .NET (e.g. 4.5 or higher) and .NET Core 2.0 and 2.1 in version 1.7.0: NuGet and release notes.

Please re-open or create a new issue if the problem persists.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants