我一直在构建一个Orchard模块,基于N-N关系教程。在将项目工作一次后,我更改了命名空间、各种类和变量名称,因为我做出了一些不成立的假设。
自从进行了这个重命名练习之后,模块(“定义列表”)在模块仪表板中显示了两次:
这是我的module.txt:
Name: Definition List AntiForgery: enabled Author: Richard Slater Website: http://www.richard-slater.co.uk/ Version: 0.2 OrchardVersion: 1.1 Description: 模块部分,用于提供可选择的定义列表作为复选框 Features: Definition List: Description: 添加定义列表部分 Category: 内容
我想不到在项目中指定其他类别的任何地方。
Migrations.cs:
public class Migrations : DataMigrationImpl {
private readonly IRepository<DefinitionRecord> _definitionListRepository;
private readonly IEnumerable<DefinitionRecord> _sampleRecords = new List<DefinitionRecord> {
new DefinitionRecord { Term = "Term A", Definition = "This is the definition for Term A" },
new DefinitionRecord { Term = "Term B", Definition = "This is the definition for Term B" },
new DefinitionRecord { Term = "Term C", Definition = "This is the definition for Term C" }
};
public Migrations(IRepository<DefinitionRecord> definitionListRepository) {
_definitionListRepository = definitionListRepository;
}
public int Create()
{
SchemaBuilder.CreateTable("DefinitionListPartRecord",
table => table
.ContentPartRecord()
);
SchemaBuilder.CreateTable("DefinitionRecord",
table => table
.Column<int>("Id", column => column.PrimaryKey().Identity())
.Column<string>("Term")
.Column<string>("Definition")
);
SchemaBuilder.CreateTable("ContentDefinitionRecord",
table => table
.Column<int>("Id", column => column.PrimaryKey().Identity())
.Column<int>("DefinitionListPartRecord_Id")
.Column<int>("DefinitionRecord_Id")
);
ContentDefinitionManager.AlterPartDefinition(
"DefinitionListPart",
builder => builder.Attachable());
if (_definitionListRepository == null)
throw new InvalidOperationException("Cannot find the Definition List Repository");
foreach (var entity in _sampleRecords) {
_definitionListRepository.Create(entity);
}
return 1;
}
}