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

GraphDiff either overwrites or update nulls to first record in case of AssociatedEntity #159

Closed sharathgt closed 8 years ago

sharathgt commented 8 years ago

`Hi,

I have below scenario

public partial class item { public int ItemId { get; set; } // other properties....

public virtual ICollection itemdetails { get; set; } public virtual itemImage itemImage { get; set; } } public partial class itemImage { //image properites... } public partial class itemdetail { public int itemdetailId { get; set; } // other properties....

public int? ItemId { get; set; } [JsonIgnore] public virtual item item { get; set; }

public int? DimensionId { get; set; } [JsonIgnore] public virtual dimension dimension { get; set; } }

public partial class dimension { public int DimensionId { get; set; } // other properties.... public virtual itemdetail itemdetail { get; set; } }

On this, I'm trying to update the DB by GraphDiff like below; _context.UpdateGraph(_item, c => c .OwnedEntity(x => x.itemImage) .OwnedCollection(x => x.itemdetails, with=>with.AssociatedEntity(z=>z.dimension)) ); This updates the record values to null with dimensionid which is equal to itemdetailsId
and if I change the with=>with.AssociatedEntity to with=>with.OwnedEntity (just for a check) it overwrites the same record with values. But It never creates a new record even if I have dimensionId is "0".

sharathgt commented 8 years ago

Its something to do with the 1-1 relationship of Entity Framework Code First and this is the wrong forum which I'm referring to. So closed the issue.