I was getting an exception from Automapper when it tried to map a List to an ICollection . The problem was that WebApi was building the MyClass from the xml sent by the client and instead of using a List for the ICollection property, it used a plain array. When Automapper tried to map the List to the Array, it failed because even though Arrays are ICollections, they do not support some of the ICollection operations, such as Add. To solve the problem, I used Json in the client side when posting. After that, webapi chose to use List instead of an Array when the data came as Json.
A blog about real-world software engineering and development problems and solutions.