How can I convert an EF4 Code-First ICollection to an EntityCollection?
问题 Say I have the following entity: public class Post { public int Id { get; set; } public virtual ICollection<Comment> Comments { get; set; } } When I retrieve a Post object from the database, I need to convert the Comments collection into an EntityCollection<T> so that I can check some EF4 related data about the collection, such as if the data was eager loaded or not. Unfortunately, if I try to do a direct cast from ICollection<T> to EntityCollection<T> , I get an exception due to the fact