The following reusable field schemas do not exist

2025/05/10 5:39 PM

Some web page types inherit from a reusable schema, some do not. The below query for my sitemap throws the error "The following reusable field schemas do not exist 'BasePage'". I ran codegen for the content types and reusable schema types. I am not sure why I am getting this error.

var b = new ContentItemQueryBuilder()
    .ForContentTypes(c => c
        .OfReusableSchema(IBasePage.REUSABLE_FIELD_SCHEMA_NAME)
        .ForWebsite(website.WebsiteChannelName))
    .InLanguage(preferredLanguageRetriever.Get());

Environment

Tags:
Content types v30.1.0

Answers

2025/05/12 6:29 PM

I'm not sure what is causing your error.

This is the same implementation I use in the Kentico Community Portal, which works.

 var b = new ContentItemQueryBuilder()
  .ForContentTypes(c => c
      .OfReusableSchema(IWebPageMeta.REUSABLE_FIELD_SCHEMA_NAME)
      .ForWebsite(website.WebsiteChannelName))
  .InLanguage(PortalWebSiteChannel.DEFAULT_LANGUAGE);

Possible causes of your problem.

  1. You are querying a different database than the one you are using the generate your content types.
  2. You have a build error so your code generation isn't actually running or your generated code is out of date compared to what is in the database.
  3. Your use of the IContentQueryExecutor is causing the problem, not the query you've constructed.
2025/05/12 7:58 PM
Answer

I am using Xperience by Kentico 30.3.1. When I run dotnet run --no-build -- --kxp-codegen --type "ReusableFieldSchemas" --location "../MVC.Entities//" --namespace "MVC.Entities"

it generates a code file like below, removing the "." from MVC.BasePage

public const string REUSABLE_FIELD_SCHEMA_NAME = "MVCBasePage";

Replacing the "." fixes the problem

Generating the ReusableFieldSchemas again, removes the "."

It appears to be a bug. I fixed the issue for now by avoiding calling .OfReusableSchema and just using .OfContentType and listing all of the webpage content types that use this schema.

2025/05/12 10:28 PM

Update: This is caused by a bug in reusable field schema name validation, not code generation. This will be fixed in an upcoming hotfix.


Reusable field schemas should not generate with a REUSABLE_FIELD_SCHEMA_NAME that includes a .. Additionally, the code name of the schema, which is the value this field refers to, should not have a . in it.

Just try this out on a new Dancing Goat project. Also look at the Kentico Community Portal.

using System;
using System.Collections.Generic;

namespace Kentico.Community.Portal.Core.Content
{
	/// <summary>
	/// Defines a contract for content types with the <see cref="IWebPageMeta"/> reusable schema assigned.
	/// </summary>
	public interface IWebPageMeta
	{
		/// <summary>
		/// Code name of the reusable field schema.
		/// </summary>
		public const string REUSABLE_FIELD_SCHEMA_NAME = "WebPageMeta";

        // ....
    }
}

The problem is that you are allowed to use a . character in the reusable field schema codename field. It doesn't appear to be correctly validated in the form field in the admin UI.

Remove the . from your schema name, regenerate your code, and try again.

To answer this question, you have to login first.