1
Vote

Can not set property value for EntityState property

description

When inserting new lines (e.g. in Test method ExtendedInvoiceTest) I ran against the error "Property set method not found" in "ObjectContextExtension.GetShallowEntity " when attaching the invoice (context.AttachObjectGraph). The problem was that upon creation of the entity clone the property EntityState does not have a setter defined.
 
I changed ObjectContextExtension.GetShallowEntity to exclude cloning properties that have no setters defined (see below) which resolved the problem.
 
if(prop.GetSetMethod() !=null)
                    prop.SetValue(clone, prop.GetValue(entity, null), null);
 
Since then my unit tests (even applied on another entity model) have all worked out very well including passing a collection of objects to be persisted in one call.
Congratulations with a great piece of work !!!

comments