Orchard开放了命令行功能,用于在快速创建代码。

由于该功能默认没有开启。系统中提供两种开启方式:

1、进入管理后台->Modules->找到[Code Generation]->点击Enable

2、使用命令行工具:输入feature enable Orchard.CodeGeneration

命令行工具的位置为:Web的bin目录下Orchard.exe。

针对codegen ,目前Orchard提供如下命令:

1、创建一个数据迁移类

命令:codegen datamigration <feature-name>

说明:这里的feature-name实际上就是Modules的名称。

补充:在指定的Modules下生成一个名为:Migrations的类。该类继承于DataMigrationImpl。

通过新增UpdateFrom1 、UpdateFrom2、UpdateFrom3 … UpdateFromN 方法操作SchemaBuilder对象的方式,来修改对应数据实体内容。

2、创建一个Module

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

说明:可以指定是否包含在解决方案中,相信这里一般都会包含。(默认值)

3、为Module创建一个测试项目

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

说明:项目名为module-name.Tests

4、创建主题

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

说明:指定参数:是否创建项目,是否包含在解决方案,继承的主题。

5、在指定Module中创建一个Controller

命令:codegen controller <module-name> <controller-name>

说明:需要指定Module名称、 Controller名称

更多命令,只需要查找系统中使用CommandNameAttribute属性的方法即可获取和扩展。

posted on 2016-02-05 11:59  我是一朵大花  阅读(933)  评论(0编辑  收藏  举报