Depeneding on what you exactly need to do, Breeze js can be the best solution. particularly, if you're using EF, you can replicate most of the functionality of the server EF's DbContext
on the client side, including, of course, the validation, but also change tracking, .saveChanges
, a simple syntax that resembles LINQ queries, caching, serializing and deserializing to allow working offline, and many other things.
The basic steps to work with Breeze js are:
- create an EF model in the server
- add a NuGet Package on the server to create Web API Services that expose the model to the client side. This is done with a surpringly low number of C# code. One of the things that this does is exposing the metadata: definition of objects, relations, and extra information, like data annotations validation info
- add a js Nuget Package for the client side which will be used to replicate the EF behavior on the client side.
Of course, not all of the functionality on the server will be replicated on the client, but you can do a lot of things:
- create new entities on the client side
- make queries on the client side, which will be executed on the server and returned to the client
- modify entities on the client: create, modify, delete...
- create relations on the client side: for example create new chlid entities in a parent object
- call
saveChanges
on the client side, which will transfer all the tracked changes to the server so that the backend is updated
- of course, while you do this, you'll get automatic client validation, and also additional server validation whenever you call
.saveChanges
Finally, you can extend and modify the server code to include some business logic, so that you can do much more than simply exposing the EF model to the client.