Quick fix for IPublishedSnapshotAccessor issues when upgrading to Umbraco 15

skttl

Søren Kottal

Posted on November 29, 2024

Quick fix for IPublishedSnapshotAccessor issues when upgrading to Umbraco 15

If you are using Umbraco ModelsBuilder in one of the SourceCode modes like me, chances are that you'll run into problems when upgrading to Umbraco 15.

Because of the new cache in Umbraco things have changed around how content is fed to the models, and with that, the IPublishedSnapshotAccessor interface has removed.

As all the ModelsBuilder models depend on that, they will fail to build, once you have upgraded the necessary NuGet packages to Umbraco.

I think the official advice is to uncomment all models and code that uses them. As a lazy dev, this is not what I want.

In stead, you can piggy back the interface back into Umbraco.

Simply, add the following snippet to one of your .generated.cs model files, and your project can build again.

namespace Umbraco.Cms.Core.PublishedCache
{
    public interface IPublishedSnapshotAccessor : IPublishedContentTypeCache { }
}
Enter fullscreen mode Exit fullscreen mode

You then have to go into Umbraco, and rebuild your models. This will generate models that are compatible with Umbraco 15, and you are good to go.

If you use IPublishedSnapshotAccessor elsewhere, you would need to refactor that code too though.

💖 💪 🙅 🚩
skttl
Søren Kottal

Posted on November 29, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related