简体   繁体   中英

How to ignore property using graphdiff?

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?

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();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM