We have a many-to-many relationship, which we specify fluently like this:
Hasmay(A=>A.Bs).WithMany(B.As)
An "A" can have zero or more "B"'s. An "B" must have one or more "A"'s.
Is there a way to specify the cardinality for the "As" in "B"?
No, because under the hood it's a 1-n-1 association. That is, A
has zero, one, or many AB
junction records, and AB
always has one B
(and always one A
).
So we're dealing with the rules of 1-n associations. There is no way to enforce a 1 - 1..n association (i.e. a parent must have at least one child), at least not in DDL. Consequently there is no way to enforce 1..n - 1..m associations. It's always 0..n - 0..m. Only by business logic you can enforce mandatory associations.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments