Take the 2-minute tour ×

After struggling for a while, in order to protect my model while style enjoying Breeze metadata, I finally created a second DbContext just for the metadata. That's the one passed to EFContextProvider. So I have one DbContext for the model, and one that serves as a data access layer, with dto's. After that I've tried hard to use automapper to automap in linq projections, but kept hitting the wall with a null reference exception. However, this library: http://linqprojector.codeplex.com/ that's related and uses the exact same syntax, works perfectly. Now, I have a method on my server that actually returns what I want: a dto, containing a list. So say I have a class Blog containing a list of Posts in the model. The method returns an object BlogDTO containing a list of PostsDTO.

BUT, in Breeze, in the BlogDTO object, the array of posts stays empty. I witness with my own eyes the data being sent to the browser, but for some reason, Breeze ignores some of it!

Honestly, there really are quite a few problems to solve going down this path.

Just wanted to share it with you guys. If anyone understands this and can help me. Here's the Breeze query:

 var query = EntityQuery
            .withParameters({id: blogId});

return manager.executeQuery(query)

function querySucceeded(data) {
            var s = data.results[0];
            return blogObservable(s);

So to be clear, in the object data, in the XHR property, the responseText property holds all the data that I want! Do I have to parse it myself? What was the point of getting my metadata down to breeze then...

share|improve this question
Ok then. After a small break and a sweet lemon beer, I've kept digging into this. When checking the results in rawEntities in breeze.debug.js, line 11394 in the executeQueryCore function, I see that well, my posts array is actually populated. Nothing is observable yet at that point. Going further, I see that it's the function mergeEntity that actually makes every property observable, and somehow loses my array. –  Nicolas Jun 6 '13 at 18:50
Breeze attempts to recognize and parse the json results into entities, if it cannot then it leaves them alone. My guess is that breeze does not have metadata for the entityTypes that you are returning. This will occur if you are returning DTO's and have not added the 'entityTypes' for these DTO's to the metadataStore. –  Jay Traband Jun 10 '13 at 20:14
Thanks for the comment (I was on holiday and could not answer earlier). I've checked what's returned by the call to Metadata on the server and all the necessary entity types are correctly returned. So the problem must be somewhere else –  Nicolas Jun 13 '13 at 14:16

2 Answers 2

up vote 0 down vote accepted

Ok I finally figured this one out. Apparently Breeze requires the InverseProperty attribute. Once that has been set, I could see my related entities!

share|improve this answer

Other important element to take into account: avoid circular references in your classes. Otherwise Breeze might just simply ignore related entities, for all I know.

share|improve this answer
Well not quite sure about this. –  Nicolas Jun 27 '13 at 7:34

Your Answer


