So I wanted to make a own custom mapper earlier but I got the advice that it is difficult(because I got refrences etc, and I agree with that ^^) and that I ll have more luck with automapper since it is easy etc. So I started creating mapping for the classes I want to convert (I want to make this application to update a SQLserver database from a SQLite file on a weekly base, the table names and properties are the same, only the capitals are not the same, but automapper is case insensitive so great)
Here is the Code I tried:
Mapper.CreateMap<person, Person>();
Mapper.CreateMap<personAbility, PersonAbility>();
Mapper.AssertConfigurationIsValid();
Then I get the error that person doesn t know how to convert the personabilities propertie. So I googled and found out that I need to include it:
Mapper.CreateMap<person, Person>()
.Include<personAbility, PersonAbility>()
Mapper.CreateMap<personAbility, PersonAbility>();
Mapper.AssertConfigurationIsValid();
However here it complains that it is not personability it needs but a list(EntityCollection). So I tried:
Mapper.CreateMap<person, Person>()
.Include<EntityCollection<personAbility>, EntityCollection<PersonAbility>>()
Mapper.CreateMap<personAbility, PersonAbility>();
Mapper.AssertConfigurationIsValid();
However it gives an error that it doesn t know the type, and I googled some more finding: https://github.com/AutoMapper/AutoMapper/wiki/Lists-and-arrays On the support list there isn t a EntityCollection. Meaning I ran into an other wall(dead end)??? Anyone knows a solution for this, if you got an other solution/way to map my database, any help will be appreciated.
I finnaly got it fixed. I was on the wrong way with include. I just needed to map the collection too
Adding this line fixed it:(and removing the include line)
Thanks for all the effort