Keeping BreezeJS magic intact with SummerBreeze


If you´re using BreezeJS to create and manage your app BDO´s on the client-side, with Entity Framework as your ORM and you have 1:1 mappings between your server and client objects, then breeze works just like magic.magician

But if you´re using DTO´s instead of the complete server-side models, or if your app relies on a different ORM framework rather than EF, or simply because you don´t have any back-end database at all, then you know you have to do a bit of “plumbing” for BreezeJS to do its job.

That happens because currently out-of the box there is no ContextProvider implemented rather than the EFContextProvider (crafted for Entity Framework). BreezeJS uses metadata to describe server-side entity types and their relationships in order to automatically map and build your business objects as “first class” breeze entities on the client-side.

If no metadata is supplied the far as you can play with the awesome BreezeJS features, is the ability to have your client side queries “translated” into valid linq queries against the IQueryable provided on the server.

This is like driving a Ferrari on a 20 mph speed limit zone.

The widely used approach is to create all the metadata by hand and include it in a model.js script file as you can see on the nodb sample.

There´s no problem at all with that but when you have quite a few business entities to create this process can turn into a real pain.

In order to overcome this situation and maintain the BreezeJS magic intact I´ve created SummerBreeze, a metadata generator library and entity creation client script to use with BreezeJS for no DB, no EF ORM or EF ORM with DTO scenarios (non 1:1 entity mappings).

With SummerBreeze the automatic entity type creation process on the client-side is kept alive.

Here are some nice features of SummerBreeze:

  • Simple inclusion – just add reference to the SummerBreeze assembly on the server and the summerbreeze.js script on the client.
  • Eazy bootstrapping – decorate your POCOS with attributes, pass the type of your datacontext or repository class that implements the ISummerBreezeDbContext interface to SummerBreezeContextProvider class, and use the summerbreeze.js script to create a generator instance to generate your entity types. Simple!
  • Property cherry picking – If you don´t want to serialize metadata from all your model´s properties, just select the ones you want by their name.
  • Wide coverage – Data Properties, Navigation Properties, Validation Properties and Unmaped Properties supported.
  • Compatibility – Can work with both EF scenarios and non-EF scenarios. It supports having both EFContextProvider and other metadata providers.
  • Entity saving – Both ways supported, not only entity creation.

I think this is a nice-to-have feature that the guys at IdeaBlade could implement on the next versions of BreezeJS. It´s a more consistent approach to what BreezeJS already does with EF, does not give you the impression that it is “tied” to a specific technology (which is not) but above all it maintains the productivity boosts that this library used us to.

SummerBreeze is available as a nuget package and you can get more information about this library at the github project site.

Go check it out.


8 thoughts on “Keeping BreezeJS magic intact with SummerBreeze

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s