问题
This question has been completely edited to actually outline the root issue after further investigation.
I was having trouble with no navigation properties appearing on my client side metadata. With deeper inspection of the breeze client side code, I've worked out that the following code in parseCsdlNavProperty
(line 6181) is causing all my collection navigation properties to be ignored:
var constraint = association.referentialConstraint;
if (!constraint) {
// TODO: Revisit this later - right now we just ignore many-many and assocs with missing constraints.
return;
// Think about adding this back later.
//if (association.end[0].multiplicity == "*" && association.end[1].multiplicity == "*") {
// // many to many relation
// ???
//} else {
// throw new Error("Foreign Key Associations must be turned on for this model");
//}
}
The property referentialConstraint is undefined, and this causes breeze to ignore my related entites. Problem is I'm not sure a) why this is null, b) what this does, c) why breeze seems to hate this, when entity framework seems to be mapping things fine, d) how to fix it.
So I've removed my entire metadata and examples of my model because it's just too much information. If there is information required, just let me know and I'll add it.
Hopefully this makes the question a little more specific and easier to decipher.
Thanks.
回答1:
The only reason that you would be missing referential constraints in your model is if the Entity Framework thinks that you are not exposing foreign keys. See Foreign keys in the Entity Framework.
Breeze requires the foreign keys in order to perform it's automatic object linking logic.
This is also described here: Breeze navigation properties
来源:https://stackoverflow.com/questions/17158159/breeze-returns-navigation-properties-in-the-metadata-but-not-on-the-entities