0

I'm trying to insert a new [Shows] record which has a 1-to-many relationship with [Performances] through a WCF service call.

The [Shows] record is created but the [Performances] records aren't. No error is thrown. How can I have the performance records created also?

Client

 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)

Service

        Dim ctx As New myEntities(ServiceURI)

        ctx.AddToShows(oShow)
        ctx.SaveChanges()
GJKH
  • 1,715
  • 13
  • 30
  • Do you see the performances properly populated on the Service side in the debugger, before calling SaveChanges()? – Eric J. Jan 09 '14 at 22:03
  • Yes, if I step through `ctx.AddToshows(oShow)` then all of the properties and the 2 Performance objects are there. Only the `Show` record is created. – GJKH Jan 09 '14 at 22:30
  • You will have to manually create those as well maybe by from the Performance property. – OneFineDay Jan 09 '14 at 22:55
  • @DonA - according to this link and every other thread I can find on it it should do this automatically - http://stackoverflow.com/questions/19546475/does-entity-framework-save-related-classes-automatically – GJKH Jan 10 '14 at 00:37

1 Answers1

0

I deleted the and recreated the edmx, the related objects are being inserted now.

GJKH
  • 1,715
  • 13
  • 30