c# - Cascade Update on Entity Framework -


i update account object has child accountprofile i'm getting exception saying attaching entity failed because entity of same type has same primary key value...

i know how update these entities accountprofile since can add/remove beneficiary objects list. possible cascade update? or create method handles these kinds of entity updates.

account class:

public class account(){     public int accountid { get; set; }     public string username { get; set; }     public int roleid { get; set; }     public int profileid { get; set; }     public virtual accountprofile profile { get; set; }     public virtual role role { get; set; } } 

accountprofile class:

public class accountprofile {     public int profileid { get; set; }     public string fullname { get; set; }     public virtual icollection<beneficiary> beneficiaries { get; set; } } 

beneficiary class:

public class beneficiary() {     public int beneficiaryid { get; set; }     public string name { get; set; } } 

edit method:

   public void edit(account account)     {         _context.entry(account).state = entitystate.modified;         _context.savechanges();                } 


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -