I am trying to copy an object (Parent) and their relationships (Children1, Children2, Children3 and Children4), creating a new id for each of them in the database but it still fails. Is there any method that can do this?
Below is the structure of objects and their relationships. Please, I need a lot to someone help me.
public class Parent
{
[PrimaryKey]
public long IdParent {get; set;}
public string Description {get; set;}
public string OtherValue {get; set;}
public virtual ICollection<Children1> Childrens1 {get; set;}
}
public class Children1
{
[PrimaryKey]
public long IdParent {get; set;}
[PrimaryKey]
public long IdChildren1 {get; set;}
public string Description {get; set;}
public virtual Parent Parent {get; set;}
public virtual ICollection<Children1> Childrens1 {get; set;}
}
public class Children2
{
[PrimaryKey]
public long IdParent {get; set;}
[PrimaryKey]
public long IdChildren1 {get; set;}
[PrimaryKey]
public long IdChildren2 {get; set;}
public string Description {get; set;}
public virtual Children1 Children1 {get; set;}
}
public class Children3
{
[PrimaryKey]
public long IdParent {get; set;}
[PrimaryKey]
public long IdChildren1 {get; set;}
[PrimaryKey]
public long IdChildren3 {get; set;}
public string Description {get; set;}
public virtual Children1 Children1 {get; set;}
public virtual ICollection<Children4> Childrens4 {get; set;}
}
public class Children3
{
[PrimaryKey]
public long IdParent {get; set;}
[PrimaryKey]
public long IdChildren1 {get; set;}
[PrimaryKey]
public long IdChildren3 {get; set;}
[PrimaryKey]
public long IdChildren4 {get; set;}
public string Description {get; set;}
public virtual Children3 Children3 {get; set;}
}