Automapper from EF(to EF) not possible?

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.

Answers


I am not positive, but you may need to create the map for PersonAbility before creating the map for Person, since mapping Person's depends on being able to map PersonAbility's


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)

        Mapper.CreateMap<EntityCollection<personAbility>, EntityCollection<PersonAbility>>();

Thanks for all the effort


Need Your Help

Why can't I use a bit field as a boolean expression in a SQL case statement?

sql design boolean case bit

I want to select something conditionally based on whether a bit field is true or false. This was the syntax that I originally tried:

Chaining with Pagedown's PreBlockGamut

javascript regex pagedown

I've tried searching online, but it seems that topics covering this subject are very scarce, and -- short of the information on PageDown's Google Code page, there doesn't seem to be too much more o...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.