zzzprojects / GraphDiff

GraphDiff is a library that allows the automatic update of a detached graph using Entity Framework code first.
https://entityframework-graphdiff.net/overview
MIT License
333 stars 102 forks source link

Update a list of children does not work #140

Closed sergiobonani closed 9 years ago

sergiobonani commented 9 years ago

Hi,

When I try to update the father adding children on a list the UpdateGraff returns a generic error:

Message: Property set method not found. StackTrace: em System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture) em System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, Object[] index) em RefactorThis.GraphDiff.Internal.Graph.GraphNode.CopyPrimaryKeyFields(IObjectContextAdapter context, Object from, Object to) na f:\Work\GitHub\GraphDiff\GraphDiff\GraphDiff\Internal\Graph\GraphNode.cs:linha 201 em RefactorThis.GraphDiff.Internal.Graph.GraphNode.CreateEmptyEntityWithKey(IObjectContextAdapter context, Object entity) na f:\Work\GitHub\GraphDiff\GraphDiff\GraphDiff\Internal\Graph\GraphNode.cs:linha 193 em RefactorThis.GraphDiff.Internal.Graph.CollectionGraphNode.AddElement[T](DbContext context, T existing, Object updateItem, Object dbCollection) na f:\Work\GitHub\GraphDiff\GraphDiff\GraphDiff\Internal\Graph\CollectionGraphNode.cs:linha 65 em RefactorThis.GraphDiff.Internal.Graph.CollectionGraphNode.Update[T](DbContext context, T existing, T entity) na f:\Work\GitHub\GraphDiff\GraphDiff\GraphDiff\Internal\Graph\CollectionGraphNode.cs:linha 45 em RefactorThis.GraphDiff.Internal.Graph.GraphNode.Update[T](DbContext context, T persisted, T updating) na f:\Work\GitHub\GraphDiff\GraphDiff\GraphDiff\Internal\Graph\GraphNode.cs:linha 55 em RefactorThis.GraphDiff.Internal.GraphDiffer1.Merge(DbContext context, T updating) na f:\Work\GitHub\GraphDiff\GraphDiff\GraphDiff\Internal\GraphDiffer.cs:linha 42 em RefactorThis.GraphDiff.DbContextExtensions.UpdateGraph[T](DbContext context, T entity, Expression1 mapping) na f:\Work\GitHub\GraphDiff\GraphDiff\GraphDiff\DbContextExtensions.cs:linha 29 em ONRP.Infraestrutura.Data.Contextos.ContextoBase.Atualizar[TEntidade](TEntidade entidade, Expression`1 mapeamento) na e:\Dev\Sergio.Bonani\ONRP\Dev\Alpha 1\Source\ONRP.Infraestrutura.Data\Contextos\ContextoBase.cs:linha 47

line implemented using the updategraph: this.UpdateGraph(entidade, map => map.OwnedCollection(x => x.Enderecos).OwnedCollection(x => x.Emails).OwnedCollection(x => x.Sociais).OwnedCollection(x => x.Telefones).OwnedEntity(x => x.Cliente).OwnedEntity(x => x.Fornecedor).OwnedEntity(x => x.Transportadora).OwnedEntity(x => x.Funcionario));

You know why this happens?

ghost commented 9 years ago

Hi,

I'm quite certain this exception is raised because one of the primary key properties of one of your entity classes does not have a setter.