0
我试图插入一个新的[Shows]
记录,它与[Performances]
通过WCF服务调用有一对多的关系。实体框架 - 插入对象与多个相关的对象
[Shows]
记录被创建,但[Performances]
记录不是。没有错误被抛出。我怎样才能创建性能记录?
客户
Dim oShow As New Show With
{
'Properties here...
}
Dim cPerformances As New Collections.ObjectModel.Collection(Of Performance)
cPerformances.Add(New Performance With
{
'Properties here...
})
cPerformances.Add(New Performance With
{
'Properties here...
})
oShow.Performances = cPerformances
Dim myServiceRef As New myWCFService.ServiceName
myServiceRef.CreateShow(oShow)
服务
Dim ctx As New myEntities(ServiceURI)
ctx.AddToShows(oShow)
ctx.SaveChanges()
在调用SaveChanges()之前,您是否在调试器中看到服务端正确填充了性能? –
是的,如果我逐步浏览'ctx.AddToshows(oShow)',那么所有属性和2个性能对象都在那里。只有'Show'记录被创建。 – GJKH
您必须手动创建这些,也可以从Performance属性中进行创建。 – OneFineDay