Skip to content

Code generation is an Orchard module that automates the task of creating additional files and extensions. This feature is useful for developers that want to create controllers, data migration classes, modules, and themes. The code generation feature is installed by default but has to be enabled by the end user/developer.

代码生成是一个Orchard模块,可以自动完成创建其他文件和扩展的任务。此功能对于想要创建控制器,数据迁移类,模块和主题的开发人员非常有用。代码生成功能默认安装,但必须由最终用户/开发人员启用。

To enable code generation, click Features under Modules, find the Code Generation feature, and click Enable.

要启用代码生成,请单击 Modules 下的 Features ,找到代代功能,然后单击启用

To enable the feature from the Orchard command-line, open the orchard command-line, and enter the following command. For more information about the Orchard command-line, see Using the command-line interface.

要从Orchard命令行启用该功能,请打开orchard命令行,然后输入以下命令。有关Orchard命令行的更多信息,请参阅[使用命令行界面](使用命令行界面)。

orchard> feature enable Orchard.CodeGeneration

Enabling features Orchard.CodeGeneration

Orchard.CodeGeneration was enabled

Once the code generation feature is enabled, new commmands are available for creating a module, theme, data migration, or controller. Currently, the code generation commands add files to the appropriate location.

启用代码生成功能后,新的命令可用于创建模块,主题,数据迁移或控制器。目前,代码生成命令将文件添加到适当的位置。

codegen controller <module-name> <controller-name>

        Create a new Orchard controller in a module



codegen datamigration <feature-name>

        Create a new Data Migration class



codegen module <module-name> [/IncludeInSolution:true|false]

        Create a new Orchard module



codegen theme <theme-name> [/CreateProject:true|false][/IncludeInSolution:true|false][/BasedOn:<theme-name>]

        Create a new Orchard theme

codegen moduletests <module-name>

        Create a new test for a module

For a walkthrough of using the code generation feature to create a new module and data migration, read the Getting Started with Modules course.

有关使用代码生成功能创建新模块和数据迁移的演练,请阅读[模块入门课程](模块入门)。

Change History

改变历史

  • Updates for Orchard 1.8

  • Orchard 1.8的更新 *

    • 9-04-14: Updated the screen shots for Code Generation Module.
  • 9-04-14:更新了代码生成模块的屏幕截图。 *