Question

If I have a POCO-Object (nothing to do with EF or any other Framework), and it looks like the following (from NoDb-Example):

public class TodoItem {
  public int TodoItemId { get; set; }
  public string Title { get; set; }
  public bool IsDone { get; set; }
}

How does Breeze know, or how do I tell Breeze, that TodoItemId is the EntityKey? Do I have to mess with the "MetaData"-By-Hand (http://www.breezejs.com/documentation/metadata-hand-depth)? I currently don't really understand, how the EntityKey-Concept can be configured/influenced.

Is there some kind of .NET-Attribute I can use? I use .NET-Framework 4.5 and Web API for the server-side.

Was it helpful?

Solution

I see you're referring to the Breeze NoDb example. That sample is all about not using Entity Framework on the server, which matches your scenario (just plain POCOs exposed via Web API).

In this style of server, no model metadata is exposed by the server so Breeze can't automatically know what entities are in your model and how they are related. Instead, you need to build this information on the client as you have correctly guessed.

To get an idea of what's involved when constructing client-side metadata, check out the Scripts\app\todo.model.js file in the Breeze NoDb example. In there you'll see how the metadata is built up and how the "isPartOfKey" attribute is used when describing the model to tell Breeze which property is the primary key.

On a side note, if you don't want to use Entity Framework for persistence but you'd like to generate the metadata automatically on the server from your POCOs you should have a read of Entity Framework as a metadata design tool in the Breeze documentation.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top