msawczyn / EFDesigner2022

Entity Framework visual design surface and code-first code generation for EF6, Core and beyond
MIT License
119 stars 21 forks source link

1 -> 0..1 relationship cannot resolve principal/dependant end #46

Closed alprinias closed 1 year ago

alprinias commented 1 year ago

Hi,

EFCore 6. I'm creating a bidirectional 1 -> 0..1 association. The modeler does not complain (and does not open the extra properties for the user to indicate which of the association ends is the pricncipal and which is the dependant). The code generates without a problem. But the migration gives a problem complaining that it cannot tell which is the dependant end.

I would expect that to be a problem for 1->1 and 0..1 -> 0..1 assoceiations but not for 1->0..1.

Best, Alex

msawczyn commented 1 year ago

Hi Alex,

I can't replicate the problem. I add two classes, draw the association, and change the cardinality from * to 0..1 image

I generate the code and can run add-migration and update-database without issue:

PM> add-migration Initial
Build started...
Build succeeded.
To undo this action, use Remove-Migration.
PM> update-database
Build started...
Build succeeded.
Applying migration '20221009131512_Initial'.
Done.
PM> 

I flipped the cardinalities around and tried again. Still no problem image

PM> add-migration Initial
Build started...
Build succeeded.
To undo this action, use Remove-Migration.
PM> update-database
Build started...
Build succeeded.
Applying migration '20221009131957_Initial'.
Done.
PM> 

Adding defined foreign key properties with each cardinality version worked as well.

alprinias commented 1 year ago

Oh, well, I can't re-reproduce it either! I suppose it will remain as one of the not-worth-the-effort-to-find-out-what-had-originally-caused-them "features". Sorry for the false alarm! Alex