.NET

Remember RIA Services? Trackable Entities Can Fill the Void

Anyone remember WCF RIA Services?  It was a great idea: simplify n-tier development with a combination of libraries and tooling. Take something which is inherently difficult, namely data-centric web services consumed by rich clients, and make it easier.  Provide a client library that performs change-tracking without dependence on Entity Framework, and a service library that can persist batch updates.  But more importantly, provide an extension to Visual Studio that generates entities based on a data model and templates for scaffolding query and update operations on the server.

Ah, but the devil is in the details.  The fatal flaw was coupling it to Silverlight.  When Silverlight bit the dust, so did RIA Services.  And it was also coupled to Windows Communication Foundation, which has declined in popularity since the arrival of ASP.NET Web API.  Another problem was the implementation, which had a lot of magic glue that was not well documented (for example, project linking and code projection).

What troubles me, however, is not that RIA Services landed in the dustbin of history – which happens all the time in the world of technology – but that it wasn’t replaced by something new and better.  We should be learning from the mistakes of the past to forge a new and better future.

So what to do about it?  Gone are the days when we can sit back and complain.  This is an era when open source has come into its own, when the infrastructure and tools are in place for developers all over the world to join together to make stuff happen.  And that’s what Trackable Entities is all about.  It’s a community effort to reduce the needless pain required to build n-tier applications with RESTful services using Entity Framework, which target any .NET client (including iOS and Android via Xamarin) and implement repository and unit of work patterns with dependency injection.

And so it is with great pleasure that I’m announcing that the Trackable Entities project has moved, from its former home on CodePlex, over to GitHub.  Why GitHub?  Suffice it to say that Microsoft has moved its important projects over to GitHub (such as ASP.NET, Core CLR, TypeScript and Roslyn).  It’s where all the cool kids are doing open source, and it has amazing tools for distributed version control and collaboration. Oh, and there’s support for Git in Visual Studio 2013 and GitHub integration for Visual Studio 2015.

GitHub also makes it easy to build online documentation.  So I’ve created a home page for Trackable Entities on GitHub which includes getting started tutorials and how-to videos (hosted on YouTube), as well as tips for debugging and ways you can contribute to the project.  Here is the URL for the Trackable Entities documentation:

So what makes Trackable Entities a viable successor to RIA Services?

To sum it up: Trackable Entities gives you just the right amount of help, without too much hand-holding or behind the scenes magic.  The client library is decoupled from the service, because all it does is set a state property: Unchanged, Added, Modified, Deleted.  That’s it really, aside from a few other helper methods.  The service library does one thing: read the state property and tell Entity Framework about it.

Secondly, there is entity code-generation based on customizable T4 templates.  These templates are used by other tools, such as the Add Entity Data Model wizard or the EF Power Tools.  But you can tweak them to your heart’s content.  There are templates for separate client / server entities, as well as shared entities, which target either .NET 4.5 or greater, or Portable Class Libraries, for compatibility across desktop and mobile platforms.

select-entities-page1

select-entities-page2

Thirdly, the Visual Studio extension for Trackable Entities provides a set of multi-project templates for creating a Visual Studio solution that includes projects for services (WCF or Web API, Repository and Unit of Work), entities (client, service or shared) and a console client (there is also a sample app which includes a WPF client using the MVVM pattern).

This is a HUGE time saver. All of the NuGet packages are installed by the template, and all the cross-project references have been set. And there is also a set of Visual Studio item templates for adding WCF services, Web API controllers, and all the classes you need to implement Repository and Unit of Work patterns.

Can’t wait to get started?  Check out these how-to videos, in which you can see me use Trackable Entities to create an n-tier application from scratch in less than 15 minutes!

One of the goals I’ve had for Trackable Entities is for it to serve as a learning tool. N-tier development is just plain hard.  But mainly it’s hard to avoid certain pitfalls in your implementation, like sending unchanged entities across the wire, failing to handle cyclical references, or not making proper use of async and await in your services.  The nice thing about the generated projects is that you can see how n-tier is done right, and you can use it to learn a set of best practices for building services that perform queries and updates in a disconnected, scalable fashion.

If you’d like to contribute to the project, check out the page in the online documentation on Contributing.  There you’ll find links to video tutorials on both Git and GitHub, as well as tips on reporting bugs and submitting good pull requests.

Happy coding!

Related Articles

Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Valeriu
Valeriu
7 years ago

The link to how-to videos is not yet functional.

Back to top button