Tuesday, 3 January 2012

Cannot cast from EntityCollection to ICollection

Unable to cast object of type 'System.Data.Objects.DataClasses.EntityCollection`1[ENTITY_TYPE]' to type 'System.Collections.Generic.ICollection`1[INSTANCE_TYPE]'.

Where ENTITY_TYPE is the Model class and INSTANCE_TYPE is some other type, perhaps an Interface.

After reading this post 'EntityCollection : ICollection', i determined the best way around this is to change the Type of your collection from ICollection to IEnumerable and then all should be well...

No comments:

Post a Comment