This project is read-only.

InvalidCastException Error during serialization EF entities

Nov 29, 2011 at 8:35 PM


I was trying to serialize an an object from Entity Framework.  It's a top level object graph and I'm getting this error message:

"Unable to cast object of type 'System.Data.Objects.DataClasses.EntityCollection`1[CaseEntities.Case]' to type 'System.Collections.ICollection'".

Is there a work around for this? 


Mar 21, 2014 at 6:23 PM
Hi, it should work in v. and above.

System.Data.Objects.DataClasses.EntityCollection does not support ICollection and therefore could not be serialized. Since 2.20 it's ok if the serialized object supports IEnumerable.