Book a Demo
Book a Demo

Benefits of the Glass Mapper version 5 Upgrade

| 27.07.2022 | 

Glass Mapper.Sc is an Object Relation Mapping (ORM) tool that gives you the ability to map data from your Sitecore solution to your code quickly and easily, using strongly typed objects. The framework allows developers to convert data from the CMS to models in your C# code so that you can spend less time mapping objects and more time solving business problems.

Glass Mapper version 5 has been around for nearly two years now, but many Sitecore installations are still lingering on version 4. This is probably because there is not enough information out there of what was wrong with version 4, what’s better in version 5, and how to get there.

Breaking changes in version 5

The upgrade documentation gives the following breaking changes:

  • SitecoreContext has changed significantly
  • GetCurrentItem method has been renamed to GetContentItem
  • Some methods require calling the context.SitecoreService
  • Disabling of lazy loading has changed
  • SitecoreService method parameters have changed.

Deprecated features and what to do instead

According to the documentation, there are a number of commonly used features in version 4 that have been deprecated in version 5, so we have put together a list and suggested ways to overcome them:

  • ISitecoreContext, GlassView, GlassContoller are obsolete and have been marked as deprecated
  • ISitecoreContext – use IMvcContext, IRequestContext, IWebFormsContext instead depending on where you are
  • GlassView – use the new Html helper methods instead
  • GlassController - Similar to ISitecoreContext, use IMvcContext instead.

So, why should you upgrade?

Sitecore 9.1+ compatibility.

Glass Mapper version 4 is compatible with Sitecore 9.0, but there is a growing list of known issues in versions 9.1+, to the extent that in Sitecore 9.3 it will break the experience editor.


This is where version 5 really shines.

To best understand, you need to follow the training as there are some important principles regarding Dependency Injection that are only covered in the training. This is mostly around correctly registering a separate ISitecoreService for every database you have as Singleton, and how to get that instance correctly in each request. This is a must-have for the built-in caching features of Glass Mapper.

Easier API

The major changes to the API are intended to make it easier to develop against and provide better abstractions for testability.

Dataweavers has completed 3 successful Glass Mapper version 5 upgrades for our clients – so why not let you help with yours?

Sitecore Cloud Infrastructure Buyers Guide

Discover the critical questions you need answered to avoid 5 key hosting and cloud infrastructure mistakes that all DX Platform owners encounter.