Quick fix for IPublishedSnapshotAccessor issues when upgrading to Umbraco 15
Søren Kottal
Posted on November 29, 2024
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 { }
}
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.
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
November 29, 2024
November 7, 2024