1 min read

Sitecore 10.1 upgrading code - check your config for Dataprovider changes

Sitecore 10.1 uses a new Dataprovider and instead of fetching all default Sitecore items from the database, Protobuf is used to get those items from a data file - fast.

Check out this blog post from Jeremy Davis that goes more in depth into this and explains perfectly what is going on:
https://jermdavis.wordpress.com/2021/03/01/v10-1s-new-database-update-strategy/

This change does mean that the default configuration for Sitecore changed slightly.

For a project we're upgrading, we used a custom configuration file to patch prefetching of items.
Upon opening the Content Tree in Sitecore, we unexpectedly saw duplicate items.

And the reason is that we added actually a 2nd DataProvider instead of patching an existing one.  
This was our custom config:

<database id="master" role:require="Standalone or ContentManagement">
   <dataProviders hint="list:AddDataProvider">
      <dataProvider ref="dataProviders/main" param1="$(id)">
         <prefetch hint="raw:AddPrefetch">
            <patch:delete />
         </prefetch>
      </dataProvider>
   </dataProviders>
</database>

Which would normally override the existing dataProvider and remove the prefetch. But the elements don't match anymore with Sitecore 10.1.
Underneath the master database configuration node, we don't have a <dataProviders hint="list:AddDataProvider"> anymore.
In Sitecore 10.1 we have a CompositeDataProvider and that contains 2 params that define the providers.

<dataProviders hint="list:AddDataProvider">
   <dataProvider type="Sitecore.Data.DataProviders.CompositeDataProvider, Sitecore.Kernel">
      <param hint="list" desc="readOnlyDataProviders">
         <protobufItems type="Sitecore.Data.DataProviders.ReadOnly.Protobuf.ProtobufDataProvider, Sitecore.Kernel">
            <filePaths hint="list">
               <filePath>/App_Data/items/$(id)</filePath>
            </filePaths>
         </protobufItems>
      </param>
      <param desc="headProvider">
         <dataProvider ref="dataProviders/main" param1="$(id)">
            <prefetch>...</prefetch>
         </dataProvider>
      </param>
   </dataProvider>
</dataProviders>

We removed our custom file to start with the default Sitecore functionality again. If necessary, you can still overwrite prefetching on the dataProviders/main. Just double check that you don't create a duplicate dataProvider by accident.