Question

In evaluating Angular + Breeze, does it support tracking changes with the consumed DTOs from services back to the backend Entity Framework?

Was it helpful?

Solution

Yes and no. Breeze tracks the changes on the client, and when you call saveChanges(), it sends the changed entities (with information about what properties changed) to the server. What happens on the server is up to you, so you could use the received data to modify the states of entities in an existing EF context, and accumulate change tracking info in EF until you decide to save it to the DB.

The provided EF + WebApi server-side components don't do that, however. They are built to streamline the following use case:

  1. Client performs add/update/delete operations on entities and calls saveChanges().
  2. Server creates a new EF DbContext and applies the changes to it.
  3. Server applies validation rules (in the BeforeSaveEntities method), and rejects the save if they fail.
  4. Server DbContext saves the changes to the database.

In this scenario, there is no long-lived EF DbContext tracking the changes; the change tracking is done on the client, and EF is used to process those changes on the server and save them in the DB.

That probably covers 90% of what most applications require, but there are hooks in place to intercept the save and make server-side changes before the save, and you can override any parts that don't fit your needs.

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