title: Entity Framework 'An item cannot be removed from a fixed size Array of type *[]'
body: <p>I am using EntityFramework to persist my entities.</p>
  
  <p>The problem I have is that when sending an entity constructed in Silverlight over a WCF to be peristed I get the error 'An item cannot be removed from a fixed size Array of type 'CarterShop.Commerce.Entities.ManufacturedItemRequirement[]'.</p>
  
  <p>I am inserting an entity (ManufacturedItem) which has an ICollection of ManufacturedItemRequirements. Entity Framework should allow me to just 'Add' this to the DbContext as a POCO object and persist this away, but for some reason it complains about the collection.</p>
  
  <p>Has anyone hit this problem before? Basically I do not know what it is complaining about. The error comes from inside System.Data:</p>
  
  <pre><code>at System.Data.Objects.Internal.PocoPropertyAccessorStrategy.CollectionRemove(RelatedEnd relatedEnd, Object value)
     at System.Data.Objects.Internal.EntityWrapper`1.CollectionRemove(RelatedEnd relatedEnd, Object value)
     at System.Data.Objects.DataClasses.EntityCollection`1.RemoveFromObjectCache(IEntityWrapper wrappedEntity)
     at System.Data.Objects.ObjectStateManager.DegradePromotedRelationships()
     at System.Data.Objects.DataClasses.RelationshipManager.AddRelatedEntitiesToObjectStateManager(Boolean doAttach)
     at System.Data.Objects.ObjectContext.AddObject(String entitySetName, Object entity)
     at System.Data.Entity.Internal.Linq.InternalSet`1.&lt;&gt;c__DisplayClass5.&lt;Add&gt;b__4()
     at System.Data.Entity.Internal.Linq.InternalSet`1.ActOnSet(Action action, EntityState newState, Object entity, String methodName)
     at System.Data.Entity.Internal.Linq.InternalSet`1.Add(Object entity)
     at System.Data.Entity.DbSet`1.Add(TEntity entity)
     at Commerce.Model.Repositories.RepositoryBase`1.Add(T entity) in C:\OclProjects 4.1\CarterShop\CarterShop.Commerce.Model\Repositories\RepositoryBase.cs:line 28
     at CarterShop.Commerce.Services.Implementation.StockItemService.CreateManufacturedItem(ManufacturedItem manufactedItem, Boolean createDefinitionAswell) in C:\OclProjects 4.1\CarterShop\CarterShop.Commerce.Services\Implementation\StockItemService.cs:line 137
  </code></pre>
  
  <p>I am basically doing:</p>
  
  <pre><code>ManufacturedItem item = new ManufacturedItem();
  item.ManufacturedItemRequirements.Add(new ManufacturedItemRequirement() { Quantity = 1; DefinitionId = 5 });
  
  // Send to WCF...
  
  Context.ManufacturedItems.Add(item); // Error thrown here.
  Context.SaveChanges();
  </code></pre>