DEV Community

Cover image for Quick fix for IPublishedSnapshotAccessor issues when upgrading to Umbraco 15
Søren Kottal
Søren Kottal

Posted on

2

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.

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

Top comments (1)

Collapse
 
sjustesen profile image
Simon Justesen • Edited

Thanks for the fix, Søren, much appreciated! I bumped into the error just now

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay