向 Kentico 页面类型添加新字段后无法编译解决方案

Not able to compile solution after adding new fields to Kentico Page Type

我们使用 Kentico 11.0.26 和 MVC。

我们有一个名为页眉的页面类型。它有几个自定义字段,一切都在 MVC 端正常运行。今天我需要添加几个新字段。添加字段后,我将 Header.cs 和 HeaderProvider.cs 的生成代码复制到 Visual Studio 中的 MVC 解决方案中。

解决方案现在无法编译。

Header.Fields 属性 中有 2 个新字段可用,但 4 个旧字段不可用。剩余的旧字段可用。

HeaderLogo 是 Intellisense 中不再可用的 4 个字段之一:

这一行:string HeaderLogo = header.Fields.HeaderLogo; 我得到以下编译器错误:

Header.HeaderFields' does not contain a definition for 'HeaderLogo' and no extension method 'HeaderLogo' accepting a first argument of type 'Header.HeaderFields' could be found (are you missing a using directive or an assembly reference?)

Header.cs 确实具有 HeaderLogo 以及所有其他字段的定义。

我建议您回滚 Header.cs 和 HeaderProvider.cs 文件并仅粘贴由 Kentico Info 和 InfoProvider 文件自动生成的新代码。换句话说不替换文件,而是合并更改。

您似乎通过替换文件删除了一些字段。问题是为什么 Kentico 不包含旧字段? - 您的数据库是最新的吗?