How to ignore property using graphdiff?

edmx graphdiff ignore properties

Question

I'm using EF6 with graphdiff and EDMX and must ignore a property of a particular entity.

How should I do since even getting the property the insert or update always leave the NULL field?

1
4
4/1/2015 1:59:37 PM

Popular Answer

The way I was able to work around this while still benefiting from the ease of GraphDiff was as follows:

  • Set your object equal to the GraphDiff method
  • Set each property you wish to ignore to .IsModified = false

(Example)

  user = db.UpdateGraph(user, map => map
            .AssociatedCollection(u => u.UserRoles)
            .AssociatedCollection(u => u.Teams));

    db.Entry(user).Property(u => u.Password).IsModified = false;
    db.Entry(user).Property(u => u.Salt).IsModified = false;

    _context.SaveChanges();
5
7/8/2015 1:12:45 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow