To-one relationship with propagating primary key

2019-01-13 Thread Ricardo Parada
Hi all, I have an entity A with a to-one relationship to entity B. The relationship is setup in eomodeler to propagate it’s primary key from A to B. I then create A and B, insert into editing context and set the to-one relationship in A to point to B. When I save changes EOF is trying to in

Re: To-one relationship with propagating primary key

2019-01-13 Thread Johann Werner
Hi Ricardo, when using pk propagation I vaguely remember that EOF is automatically creating an instance of the dependent entity. Thus when you create a second object B and set the relationship to A the auto created object is left without connection. jw > Am 13.01.2019 um 12:44 schrieb Ricardo

Re: To-one relationship with propagating primary key

2019-01-13 Thread Ricardo Parada
Hi Johann, My workaround is to model the relationship as a to-many propagating the primary key. It’s less elegant but at least it works. Thanks Ricardo > On Jan 13, 2019, at 7:02 AM, Johann Werner wrote: > > Hi Ricardo, > > when using pk propagation I vaguely remember that EOF is automat

Re: To-one relationship with propagating primary key

2019-01-13 Thread Johann Werner
Hi Ricardo, don’t fight the system ;-) When you have your to-one relationship A -> B with key propagation just create an instance of A and you automatically have a B in place when you check the relationship A.toB(). You just have to (re)use the present B instead of creating and connecting your

Re: To-one relationship with propagating primary key

2019-01-13 Thread Ricardo Parada
When I create A will it have a B set in the to-one? Ricardo > On Jan 13, 2019, at 12:35 PM, Johann Werner wrote: > > Hi Ricardo, > > don’t fight the system ;-) > > When you have your to-one relationship A -> B with key propagation just > create an instance of A and you automatically have a B

Re: To-one relationship with propagating primary key

2019-01-13 Thread Johann Werner
> Am 13.01.2019 um 18:37 schrieb Ricardo Parada : > > When I create A will it have a B set in the to-one? I think so. It is a lng time ago I used key propagation though. > > Ricardo > >> On Jan 13, 2019, at 12:35 PM, Johann Werner wrote: >> >> Hi Ricardo, >> >> don’t fight the system

Re: To-one relationship with propagating primary key

2019-01-13 Thread Ricardo Parada
Yes it did. That was the problem. And now that you both mention the logic behind it makes total sense. Thank you Johann and Aaron. Ricardo > On Jan 13, 2019, at 12:42 PM, Johann Werner wrote: > > > >> Am 13.01.2019 um 18:37 schrieb Ricardo Parada : >> >> When I create A will it have a B

Re: To-one relationship with propagating primary key

2019-01-13 Thread Aaron Rosenzweig
Wait a second… thinking about this more. If you are going A -> B where A has a primary key and you have a two one relationship to B where you “propagate” primary key - this is a very bad thing!! What it means is the PK of A also points to the PK of B… it will always think there is a B… so