C# breezejs-如何添加新的子实体并将其附加到父实体';儿童收藏

C# breezejs-如何添加新的子实体并将其附加到父实体';儿童收藏,c#,knockout.js,breeze,one-to-many,hottowel,C#,Knockout.js,Breeze,One To Many,Hottowel,我有一个来自数据库的具有导航属性的模型。模型的结构如下所示 public class Parent{ public string propertyone {get; set;} public IList<Child> children {get; set;} } public class Child{ public string propertyone {get; set;} public string propertytwo {get; set;} publ

我有一个来自数据库的具有导航属性的模型。模型的结构如下所示

public class Parent{
  public string propertyone {get; set;}
  public IList<Child> children {get; set;}
}

public class Child{ 
  public string propertyone {get; set;}
  public string propertytwo {get; set;}
  public IList<Seed> children {get; set;}
}

这和add函数中的注释行都是我尝试过的,但都不起作用。我收到错误,
未定义不是函数
。如何向此导航集合中添加一个表示父实体和子实体之间一对多关系的项?

如果元数据设置正确,则所需的只是:

entityType.createEntity({ parentIdProperty: 'parent id value' });

这将创建实体并将其添加到父实体的集合。

是否使用实体框架?如果元数据设置正确,则只需
entityType.createEntity({parentIdProperty:'parent id value'})
。这将创建实体并将其添加到父实体的集合中。谢谢!!是的,我用的是EF,你的陈述是正确的。它实际上正在被添加。如果你把它作为答案贴出来,我会接受的
function add(parent){
  var newchild= ko.observable(entityType.createEntity(
                        {
                            propertyone : "Test"

                        }));
  parent.children.push(newchild);
  //parent().children().push(newchild);
  //self.parent.children.push(newchild);
  //self.parent().children().push(newchild);
}
entityType.createEntity({ parentIdProperty: 'parent id value' });